필터 지우기
필터 지우기

How to vectorize if statement

조회 수: 1 (최근 30일)
Master Blabla
Master Blabla 2020년 11월 19일
편집: Master Blabla 2020년 11월 19일
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일
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일
you can try:
[aSortV,aSortI] = sort(c,'ascend');
f = 0;
if(m < 7 && m < sm*0.3)
f = aSortI(1);
end

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by