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 Center および File ExchangeMATLAB についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by