Stop Excuting some lines

1 view (last 30 days)
koko kinder
koko kinder on 29 Jan 2012
I have a while loop which goes throw some commands. I want the while loop to execute some of the commands only once while the others should be executed infinitely. I cannot remove these statement outside the loop as they are important in there location. So, is there a way to jump over them after the first execution without disturbing the loop.

Accepted Answer

David Young
David Young on 29 Jan 2012
flag = 1;
while <condition>
<commands to be always executed>
if flag
<commands to be executed only on first iteration>
end
<commands to be always executed>
if flag
<commands to be executed only on first iteration>
end
< ... >
flag = 0;
end

More Answers (0)

Categories

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

Tags

Community Treasure Hunt

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

Start Hunting!