How to vectorize if statement
조회 수: 1 (최근 30일)
이전 댓글 표시
How to vectorize this if statement
f = 0;
if(m < 7)
if(m < sm*0.3)
f = 5;
end
end
댓글 수: 1
James Tursa
2020년 11월 19일
What is m and sm? What do you actually want as a result for f? You don't show a loop so I am not sure what you want vectorized.
채택된 답변
David Hill
2020년 11월 19일
Looks like f is just a scalar. No vectorization needed.
if m<7&&m<sm*.3
f=aSortI(1);
else
f=0;
end
댓글 수: 0
추가 답변 (1개)
Setsuna Yuuki.
2020년 11월 19일
you can try:
[aSortV,aSortI] = sort(c,'ascend');
f = 0;
if(m < 7 && m < sm*0.3)
f = aSortI(1);
end
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Get Started with MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!