MATLAB Answers

# maximum value of matrix

2 views (last 30 days)
ha ha on 16 Aug 2019
Edited: ha ha on 16 Aug 2019
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 ?
##### 0 CommentsShowHide -1 older comments

Sign in to comment.

### Accepted Answer

madhan ravi on 16 Aug 2019
[Val,ix]=max(A(:));
[r,~]=ind2sub(size(A),ix);
A(r,:) %complete row where maximum exists
##### 5 CommentsShowHide 4 older comments
madhan ravi on 16 Aug 2019
[Val,ix]=max(A(:));
[r,c]=ind2sub(size(A),ix);
Wanted = A(r,setdiff(1:size(A,2),c))

Sign in to comment.

### More Answers (2)

KSSV on 16 Aug 2019
[val,idx] = max(A(:)) ;
A(idx,:)
##### 1 CommentShowHide None
ha ha on 16 Aug 2019
Your answer is wrong. Plz check it again

Sign in to comment.

ha ha on 16 Aug 2019
[Val,ix]=max(A(:));
[r,c]=ind2sub(size(A),ix);
A(r,setdiff(1:size(A,2),c),:);
##### 2 CommentsShowHide 1 older comment
ha ha on 16 Aug 2019
Sorry madhan ravi.
Thank so much for your prompt reply
Hope all bests to you.

Sign in to comment.

### Tags

No tags entered yet.

### Community Treasure Hunt

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

Start Hunting!