and another "if" statement question
2 ビュー (過去 30 日間)
古いコメントを表示
Hi guys,
I am stuck on a coding project. Any suggestions/insight would be very appreciated! Thanks in advance.
For my "if" statement, I want to compare a vector of values A = [1 2 3 4 5 6] with a singular value, say 3. Essentially, if every element within A is greater than 3, I wish to continue some operations. If not, I wish to go on to the next iteration in my for loop.
Is there is an efficient way of performing this?
Much thanks!
0 件のコメント
採用された回答
Matt Kindig
2013 年 9 月 23 日
How long is the vector? Would this work?
if all(A>3)
%do something
else
%do other thing
end
0 件のコメント
その他の回答 (1 件)
Image Analyst
2013 年 9 月 23 日
for k = 1 : 100000
if any(A <= 3)
% Skip to end of loop but continue with next iteration if any are <= 3.
continue;
end
% Else continues with the rest of the loop.
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!