Alternative to "continue"
7 ビュー (過去 30 日間)
古いコメントを表示
Hello, is there any alternative to that continue?

0 件のコメント
回答 (2 件)
Image Analyst
2017 年 12 月 6 日
You could wrap everything in an if
for .......
if m == 0
% Code you want to run
else
fprintf('O Username deve .............
end
end
That doesn't use a continue.
3 件のコメント
Walter Roberson
2017 年 12 月 6 日
The code you display here has no way to exit the while loop, because nothing changes x . We must suspect that after the if m ~= 0 that you have more code that might change x, with the general structure
while x == true
some code here
if m ~= 0
display error
continue;
end
some more code here
end
You would change that to
while x == true
some code here
if m ~= 0
display error
else
some more code here
end
end
Guillaume
2017 年 12 月 6 日
- Why do you ask?
- Programming languages are efficient. This means that if there is an instruction to do something, there's not going to be another one to do the exact same thing.
- Maybe there is an alternative but that would depend on the for loop that encloses the piece of code you've shown, so you've not even shown enough code to answer your question.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Performance and Memory についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
