Clear Filters
Clear Filters

How do you print only the final iteration of a for loop?

4 views (last 30 days)
If I use a semi-colon, it suppresses all the output. But if I don't use one, it prints out every iteration. What do I use to only print out the final iteration of a for loop?

Accepted Answer

José-Luis
José-Luis on 2 Jan 2017
Edited: José-Luis on 2 Jan 2017
for ii = 1:10
display_me = %something;
end
display_me
You could add an if statement inside the loop to avoid unnecessary copying.
Please accept the answer that best solves your problem.

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!