maximum value of matrix
1 view (last 30 days)
Show older comments
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 Comments
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 Comments
Stephen23
on 16 Aug 2019
>> 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
on 16 Aug 2019
[Val,ix]=max(A(:));
[r,c]=ind2sub(size(A),ix);
Wanted = A(r,setdiff(1:size(A,2),c))
More Answers (2)
ha ha
on 16 Aug 2019
2 Comments
madhan ravi
on 16 Aug 2019
What’s the hurry before editing the comment?? XD . I was using my mobile to answer and I just mistyped the colon inside setdiff().
See Also
Categories
Find more on Filter Analysis in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!