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

1 comentario

James Tursa
James Tursa el 19 de Nov. de 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.

Iniciar sesión para comentar.

 Respuesta aceptada

David Hill
David Hill el 19 de Nov. de 2020

0 votos

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

Más respuestas (1)

Setsuna Yuuki.
Setsuna Yuuki. el 19 de Nov. de 2020

0 votos

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

Categorías

Más información sobre MATLAB en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 19 de Nov. de 2020

Editada:

el 19 de Nov. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by