finding the max ?

1 Ansicht (letzte 30 Tage)
diadalina
diadalina am 4 Dez. 2018
Bearbeitet: diadalina am 4 Dez. 2018
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 ?

Akzeptierte Antwort

Guillaume
Guillaume am 4 Dez. 2018
maxvalue = max(x);
positions = find(x == maxvalue);
No loop needed
  1 Kommentar
diadalina
diadalina am 4 Dez. 2018
thank you mr,Guillaume, i founde it,

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by