在 Python 中,我们有一个方便的函数 enumerate
:
for i,item in enumerate(foo_list):
do something
有没有等价于enumerate
的Matlab?
目前,我能想到的是如下(Matlab代码):
i=1;
for foo=foo_list
....
i=i+1;
end
最佳答案
据我所知,Matlab 中没有枚举的等价物。最常见的方法是:
for i = 1:length(foo_list)
item = foo_list(i);
% do stuff with i, item
end
关于python - Python 枚举的 Matlab 等价物,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25469168/