Info

この質問は閉じられています。 編集または回答するには再度開いてください。

How to find which element is the lowest first or second or third or ....

4 ビュー (過去 30 日間)
Chamira Wickramasinghe
Chamira Wickramasinghe 2015 年 3 月 5 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
There is a 1X1 matrix.
I wanna find which element is the MINIMUM not the minimum value but the number of the particular element.
If this is the matrix,
y = [682.8333 399.8160 34.2270 46.1800 107.7035 ];
I know the minimum value is 34.2270 to get that we can use
mini= min(y);
but what i want is how to get the number of the minimum element
in here it's the 3rd element.
Thank you.

回答 (1 件)

Star Strider
Star Strider 2015 年 3 月 5 日
Use the min function with two outputs:
[mini,index] = min(y);
The second output, ‘index’ here, is the index of the first minimum value the function finds.
  2 件のコメント
Chamira Wickramasinghe
Chamira Wickramasinghe 2015 年 3 月 5 日
Woooow it worked just like that
Thank u for your concern and answer.
Star Strider
Star Strider 2015 年 3 月 5 日
My pleasure!
If it solved your problem, I would appreciate it if you would Accept it.

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by