-1
我有一個程序,所有的功能都在for循環中。如果條件成立,我想跳過一些變量以避免做任何事情。例如:如何跳過for循環的一些迭代並在Matlab中執行其他迭代?
for i=1:a
for j=1:b
if counter=101
%until i<21 do nothing then if i=21 continue the loop and do what I want
% until i=23, after that again i goes forward but don't do any thing
%until i=44 again do the progress and continue the loop.
end
%do what I want
end
end
但我無法得到正確的答案。 我把它寫下來一樣:
if counter==101
j=1;
while (i < a/3+1)
i=i+1;
continue
end
end
if counter==201
j=1;
while (i < 2*a/3+1)
i=i+1;
continue
end
end
在這段代碼中,I = 21後的循環重複做,之後,在我去號碼前21(例如3),但我不希望它。 如果有人有建議,將不勝感激。
請更正代碼的層次結構 – OmG