and another "if" statement question
조회 수: 1(최근 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
참고 항목
범주
Find more on Loops and Conditional Statements in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!