maximum value of matrix

조회 수: 1 (최근 30일)
ha ha
ha ha 2019년 8월 16일
편집: ha ha 2019년 8월 16일
let's say , I have matrix
A=[3 1;4 9 ;5 7 ];
A=[3 1
4 9
5 7 ];
I can find the maximum value from matrix A is 9:
max_value=max(max(A));
How can I get the value is in same row of 9, that is, 4 ?

채택된 답변

madhan ravi
madhan ravi 2019년 8월 16일
[Val,ix]=max(A(:));
[r,~]=ind2sub(size(A),ix);
A(r,:) %complete row where maximum exists
  댓글 수: 5
Stephen23
Stephen23 2019년 8월 16일
>> A = [3,1;4,9;5,7]
A =
3 1
4 9
5 7
>> [V,X] = max(A(:));
>> [R,C] = ind2sub(size(A),X);
>> A(R,3-C)
ans = 4
madhan ravi
madhan ravi 2019년 8월 16일
[Val,ix]=max(A(:));
[r,c]=ind2sub(size(A),ix);
Wanted = A(r,setdiff(1:size(A,2),c))

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

추가 답변 (2개)

KSSV
KSSV 2019년 8월 16일
[val,idx] = max(A(:)) ;
A(idx,:)
  댓글 수: 1
ha ha
ha ha 2019년 8월 16일
편집: ha ha 2019년 8월 16일
Your answer is wrong. Plz check it again

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


ha ha
ha ha 2019년 8월 16일
[Val,ix]=max(A(:));
[r,c]=ind2sub(size(A),ix);
A(r,setdiff(1:size(A,2),c),:);
  댓글 수: 2
madhan ravi
madhan ravi 2019년 8월 16일
What’s the hurry before editing the comment?? XD . I was using my mobile to answer and I just mistyped the colon inside setdiff().
ha ha
ha ha 2019년 8월 16일
편집: ha ha 2019년 8월 16일
Sorry madhan ravi.
Thank so much for your prompt reply
Hope all bests to you.

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

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by