フィルターのクリア

Locating Row and Column of Min. Value

2 ビュー (過去 30 日間)
Mark Coughlin
Mark Coughlin 2020 年 10 月 22 日
回答済み: KSSV 2020 年 10 月 22 日
Hi,
I am trying to find the first location where the minimum value is found. Below is my script so far:
x=[5 6 78 32;
34 1 7 2;
23 4 7 1];
k=min(x(:));
[row column]=find(x==k)
This script returns the row and column location of both minimums, however I just need to know the first.
Any help would be appreciated! Thankyou
  1 件のコメント
KSSV
KSSV 2020 年 10 月 22 日
[row(1) column(1)]

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

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 22 日
編集済み: Ameer Hamza 2020 年 10 月 22 日
[row column]=find(x==k,1)
%^ pass 1 here
Alternatively
x=[5 6 78 32;
34 1 7 2;
23 4 7 1];
[~, idx] = min(x, [], 'all', 'linear');
[r, c] = ind2sub(size(x), idx);

その他の回答 (1 件)

KSSV
KSSV 2020 年 10 月 22 日
[row column]=find(x==k,1)

カテゴリ

Help Center および File ExchangeEnvironment and Settings についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by