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 中查找有关 Filter Analysis 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by