How to vectorize if statement
Mostra commenti meno recenti
How to vectorize this if statement
f = 0;
if(m < 7)
if(m < sm*0.3)
f = 5;
end
end
1 Commento
James Tursa
il 19 Nov 2020
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.
Risposta accettata
Più risposte (1)
Setsuna Yuuki.
il 19 Nov 2020
you can try:
[aSortV,aSortI] = sort(c,'ascend');
f = 0;
if(m < 7 && m < sm*0.3)
f = aSortI(1);
end
Categorie
Scopri di più su MATLAB in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!