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!
Tuesday, June 16, 2009
Thursday, June 11, 2009
saving .mat file as per the iteration
I wanted to save the mat files as the iteration progressed.
here is the quick solution:
it saves the mat file with number of iteration as the file name: viz: 100.mat, 200.mat etc.
This is handy when you want to compare the results of the intermediate results as you progress the iteration.
here is the quick solution:
it saves the mat file with number of iteration as the file name: viz: 100.mat, 200.mat etc.
This is handy when you want to compare the results of the intermediate results as you progress the iteration.
Subscribe to:
Posts (Atom)