For loop repeat itself for a given number of input. The syntax for “For Loop Matlab” is
for variable = expression
Program Statement
end
In the above syntax, the expression has one of the following forms.
Initial value : Final value
for x = 1:10
fprintf('value of x: %d\n', x);
end
Initial value : Step : Final value
for x = 1:2:10
fprintf('value of x: %d\n', x);
end
Value Array
for x = [1 4 6 8 90]
disp(x)
end
2 Comments
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/31156-how-do-i-create-a-for-loop-in-matlab#comment_453803
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/31156-how-do-i-create-a-for-loop-in-matlab#comment_453803
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/31156-how-do-i-create-a-for-loop-in-matlab#comment_453826
Direct link to this comment
https://nl.mathworks.com/matlabcentral/answers/31156-how-do-i-create-a-for-loop-in-matlab#comment_453826
Sign in to comment.