MATLAB Answers

finding the max ?

1 view (last 30 days)
diadalina
diadalina on 4 Dec 2018
Edited: diadalina on 4 Dec 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 ?

  0 Comments

Sign in to comment.

Accepted Answer

Guillaume
Guillaume on 4 Dec 2018
maxvalue = max(x);
positions = find(x == maxvalue);
No loop needed

  1 Comment

diadalina
diadalina on 4 Dec 2018
thank you mr,Guillaume, i founde it,

Sign in to comment.

More Answers (0)

Tags


Translated by