maximum value of matrix

3 visualizaciones (últimos 30 días)
ha ha
ha ha el 16 de Ag. de 2019
Editada: ha ha el 16 de Ag. de 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 ?

Respuesta aceptada

madhan ravi
madhan ravi el 16 de Ag. de 2019
[Val,ix]=max(A(:));
[r,~]=ind2sub(size(A),ix);
A(r,:) %complete row where maximum exists
  5 comentarios
Stephen23
Stephen23 el 16 de Ag. de 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
madhan ravi el 16 de Ag. de 2019
[Val,ix]=max(A(:));
[r,c]=ind2sub(size(A),ix);
Wanted = A(r,setdiff(1:size(A,2),c))

Iniciar sesión para comentar.

Más respuestas (2)

KSSV
KSSV el 16 de Ag. de 2019
[val,idx] = max(A(:)) ;
A(idx,:)
  1 comentario
ha ha
ha ha el 16 de Ag. de 2019
Editada: ha ha el 16 de Ag. de 2019
Your answer is wrong. Plz check it again

Iniciar sesión para comentar.


ha ha
ha ha el 16 de Ag. de 2019
[Val,ix]=max(A(:));
[r,c]=ind2sub(size(A),ix);
A(r,setdiff(1:size(A,2),c),:);
  2 comentarios
madhan ravi
madhan ravi el 16 de Ag. de 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().
ha ha
ha ha el 16 de Ag. de 2019
Editada: ha ha el 16 de Ag. de 2019
Sorry madhan ravi.
Thank so much for your prompt reply
Hope all bests to you.

Iniciar sesión para comentar.

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by