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 日

0 投票

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

1 件のコメント

diadalina
diadalina 2018 年 12 月 4 日
thank you mr,Guillaume, i founde it,

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

質問済み:

2018 年 12 月 4 日

編集済み:

2018 年 12 月 4 日

Community Treasure Hunt

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

Start Hunting!

Translated by