i have a vector x=[-1,5,3,4,5]
i want to calculate the max of the vector x and its position using the loop for, i want also to extract the two position here we have max =5, the first position is i1=2 and the second i2=5, how can i do this, can anyone help me ?

 Respuesta aceptada

Guillaume
Guillaume el 4 de Dic. de 2018

0 votos

maxvalue = max(x);
positions = find(x == maxvalue);
No loop needed

1 comentario

diadalina
diadalina el 4 de Dic. de 2018
thank you mr,Guillaume, i founde it,

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 4 de Dic. de 2018

Editada:

el 4 de Dic. de 2018

Community Treasure Hunt

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

Start Hunting!

Translated by