minimum row value and return the row

조회 수: 14 (최근 30일)
azie
azie 2013년 7월 18일
답변: Heba Khaled 2021년 5월 16일
i need to find a minimum row value in a matrix. eg
A=[12 64 76; 34 10 27; 9 8 20; 10 30 8]
And the desired output would be min value of row = [9 8 20] which is row number 3.
is there any function can do this? I noticed that min () function is used to find the minimum value in a row NOT minimum row value.
  댓글 수: 1
Matthew Anderson
Matthew Anderson 2016년 2월 23일
This might be a little late, but the min(min()) function would do the trick

댓글을 달려면 로그인하십시오.

채택된 답변

Teja Muppirala
Teja Muppirala 2013년 7월 18일
Do you mean to say, you want the row with the minimum maximum value?
A=[12 64 76; 34 10 27; 9 8 20; 10 30 8];
[value,ind] = min(max(A,[],2));
A(ind,:)
ans =
9 8 20
Or
A = [ 7 9 5; 3 8 7; 4 5 6]
[value,ind] = min(max(A,[],2));
A(ind,:)
ans =
4 5 6
  댓글 수: 1
azie
azie 2013년 7월 18일
편집: azie 2013년 7월 18일
thanks teja. actually i dont understand how its works. but it works for my case. ur second choice. if u can explain what min max mean would be better.thanks. max(A,[],2) : what is 2 stands for?

댓글을 달려면 로그인하십시오.

추가 답변 (3개)

Roger Stafford
Roger Stafford 2013년 7월 18일
You have not told us what aspect of rows you are minimizing. I will guess you want the row index of the row with the least sum.
[c,ix] = min(sum(A,2));
The value 'c' is the minimum row sum and 'ix' is that row's index.
  댓글 수: 1
azie
azie 2013년 7월 18일
the value for each column can't be sum up.each column is different. just need the lowest row value.

댓글을 달려면 로그인하십시오.


James Tursa
James Tursa 2013년 7월 18일
편집: James Tursa 2013년 7월 18일
If you want row that contains the minimum value (it is not clear to me what "minimum row" means):
[x xi] = min(A(:));
xij = ind2sub(xi,size(A));
minrow = A(xij(1),:);
  댓글 수: 3
James Tursa
James Tursa 2013년 7월 18일
Can you please define what "minimum row" means? What is the minimum row of the following matrix (and why)?
[ 7 9 5;
3 8 7;
4 5 6]
azie
azie 2013년 7월 18일
편집: azie 2013년 7월 18일
the minimum row value will be [4 5 6]. the minimum value that we can get in a row.

댓글을 달려면 로그인하십시오.


Heba Khaled
Heba Khaled 2021년 5월 16일
how to get the minimum value of particular rows in matlab

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by