Locating Row and Column of Min. Value

조회 수: 1 (최근 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

채택된 답변

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 CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by