This is a nice example.
This takes x until y(j)>50. After the condition is met it simply passes out.
Better explained by:
continue keeps on taking values does not break the chain.
while break breaks it and comes out of the loop
Contrasted over the
lastly;
clear
clc
y = 1:100;
count = 0
for j = 1:length(y)
disp('go')
if y(j)<20||y(j)>50, break, end
count = count+1
x(j)=y(j)
pause
end
this does not even work while continue will keep looking for the situation.
Break just breaks while continue keep working escaping to the next one and checking!
No comments:
Post a Comment