How to vectorize if statement
10 次查看(过去 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 中查找有关 Loops and Conditional Statements 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!