## maximum value of matrix

Asked by ha ha

### ha ha (view profile)

on 16 Aug 2019 at 9:45
Latest activity Edited by ha ha

### ha ha (view profile)

on 16 Aug 2019 at 10:51

### madhan ravi (view profile)

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 (view profile)

on 16 Aug 2019 at 10:01

[Val,ix]=max(A(:));
[r,~]=ind2sub(size(A),ix);
A(r,:) %complete row where maximum exists

ha ha

### ha ha (view profile)

on 16 Aug 2019 at 10:22
you assumed that , the value "4" is in the 1st column of matrix A. But, actually, I don't know where it is (It may be in 1st or 2nd column of matrix A)
Thanks so much madhan ravi
Stephen Cobeldick

### Stephen Cobeldick (view profile)

on 16 Aug 2019 at 10:31
>> 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 (view profile)

on 16 Aug 2019 at 10:32
[Val,ix]=max(A(:));
[r,c]=ind2sub(size(A),ix);
Wanted = A(r,setdiff(1:size(A,2),c))

### KSSV (view profile)

on 16 Aug 2019 at 9:47

[val,idx] = max(A(:)) ;
A(idx,:)

ha ha

### ha ha (view profile)

on 16 Aug 2019 at 9:55
Your answer is wrong. Plz check it again

Answer by ha ha

### ha ha (view profile)

on 16 Aug 2019 at 10:31

[Val,ix]=max(A(:));
[r,c]=ind2sub(size(A),ix);
A(r,setdiff(1:size(A,2),c),:);

### madhan ravi (view profile)

on 16 Aug 2019 at 10:39
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 (view profile)

on 16 Aug 2019 at 10:48