How to vectorize this if statement
f = 0;
if(m < 7)
if(m < sm*0.3)
f = 5;
end
end

댓글 수: 1

James Tursa
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
David Hill 2020년 11월 19일

0 개 추천

Looks like f is just a scalar. No vectorization needed.
if m<7&&m<sm*.3
f=aSortI(1);
else
f=0;
end

추가 답변 (1개)

Setsuna Yuuki.
Setsuna Yuuki. 2020년 11월 19일

0 개 추천

you can try:
[aSortV,aSortI] = sort(c,'ascend');
f = 0;
if(m < 7 && m < sm*0.3)
f = aSortI(1);
end

카테고리

도움말 센터File Exchange에서 MATLAB에 대해 자세히 알아보기

태그

질문:

2020년 11월 19일

편집:

2020년 11월 19일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by