Matlab for loop code example
Example 1: for matlab
s = 10;
for c = 1:s
%some code
end
%%foreach like
for v = [1 5 8 17]
disp(v)
end
Example 2: matlab for
for v = 0.0:+0.2:1.0
disp(v)
end
% Console Output:
% 0
% 0.2
% 0.4
% 0.6
% 0.8
% 1
Example 3: python for loop
nums = ['one', 'two', 'three']
for elem in nums:
print(elem)
Example 4: for each loop matlab
elements = 6:2:12;
for element = elements
% Do stuff with element
disp(element);
end