How can I which value that be used to calculate a function

1 回表示 (過去 30 日間)
Tianze Li
Tianze Li 2019 年 5 月 14 日
コメント済み: Fangjun Jiang 2019 年 5 月 17 日
In this casue, I difine a range for x and y, and then calculated the min value of L, but how do i find which x vaule and y value to calculate the min L? Many thanks!!!!!

採用された回答

Fangjun Jiang
Fangjun Jiang 2019 年 5 月 14 日
編集済み: Fangjun Jiang 2019 年 5 月 14 日
You need to run min() twice
A=magic(5);
[MinInCol,RowIndex]=min(A);
[MinValue,ColIndex]=min(MinInCol);
Position=[RowIndex(ColIndex),ColIndex];
or better
[MinValue,Index]=min(A(:));
[Ix,Iy]=ind2sub(size(A),Index)
  2 件のコメント
Tianze Li
Tianze Li 2019 年 5 月 17 日
Yes. It did show the row and coloum for both x and y. But how can i display the value from that row and coloum instead of to find them from the array
Fangjun Jiang
Fangjun Jiang 2019 年 5 月 17 日
Not clear what you mean. Maybe in your example, you are looking for x(Ix), y(Iy)?

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

その他の回答 (1 件)

Steven Lord
Steven Lord 2019 年 5 月 14 日
Since you indicate that you're using release R2019a, call min with the 'linear' option and two output arguments. This will give you the linear index of the minimum value, and you can use that index into x and y.

カテゴリ

Help Center および File ExchangeMatrices and Arrays についてさらに検索

タグ

タグが未入力です。

製品


リリース

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by