How to use continue to skip the rest of the iteration and go to the new iteration?
1 view (last 30 days)
Show older comments
Hi all, I am not sure if I an using my 'continue' properly since my values are starting to look weird at a point where I start using 'continue'.
Could you please tell me if my comments match the functions of 'continue' and 'break'?
for row = 1:88
if isnan(AU(row, col)) %------------------------------------------Current value missing.
while1TF = true;
while while1TF
prev = AU(row-1, col-1);
next = AU(row, col+1);
count=0;
while 1
if not(isnan(next))
break; %break from the inner-while loop
else
count = count + 1;
next = AU(row, col+1+count);
end
end
if not(isnan(prev))
while1TF = false; %from the outer-while loop
end
end
row = row - 1;
col = col + 1 + count;
elseif isnan(AU(row + 1, col)) %-------------------------------------Next value missing.
prev = AU(row, col);
diagonal = AU(row+1, col+1);
if isnan(diagonal)
col = col + 1;
continue; %Skips calculation, and enters the for loop for the next 'row' value.
else
next = AU(row+1, col+1);
col = col + 1; %used to be outside of if-statement.
end
else %--------------------------Keep going down the rows as long as the next row exists.
prev = AU(row, col);
next = AU(row + 1, col);
end
if prev > next
comp(row+1,1) = -1;
elseif prev < next
comp(row+1,1) = 1;
else
comp(row+1,1) = comp(row,1); %If the two comparables are the same, use the previous value (-1 or 1).
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Subplots 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!