finding the max ?

1 次查看(过去 30 天)
diadalina
diadalina 2018-12-4
编辑: diadalina 2018-12-4
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 ?

采纳的回答

Guillaume
Guillaume 2018-12-4
maxvalue = max(x);
positions = find(x == maxvalue);
No loop needed

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by