How do I convert from a while loop to a for loop?

2 views (last 30 days)
i = 0;
while (i < 110)
fprintf('i = %d\n',i)
i = i + 11;
end

Accepted Answer

James Tursa
James Tursa on 4 Nov 2015
for i=0:11:109
fprintf('i = %d\n',i)
end

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!