For Loops: MATLAB vs Python
1. Loop with Index
MATLAB
-------------
for i = 1:length(v)
val = v(i);
disp(val)
end
Python
-------------
for i in range(len(v)):
val = v[i]
print(val)
2. Loop through Values Only
MATLAB
-------------
for val = v
disp(val)
end
Python
-------------
for val in v:
print(val)
3. Loop with Index and Value
MATLAB
-------------
for i = 1:length(v)
val = v(i);
disp(i)
disp(val)
end
Python
-------------
for i, val in enumerate(v):
print(i, val)