In Python, we have a convenient function enumerate
:
for i,item in enumerate(foo_list):
do something
Is there a Matlab equivalent to enumerate
?
For now, what I can think of is something like the following (Matlab code):
i=1;
for foo=foo_list
....
i=i+1;
end
As far as I know, there is no equivalent of enumerate in Matlab. The most common way to do this is:
for i = 1:length(foo_list)
item = foo_list(i);
% do stuff with i, item
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With