Getting the entry value (i,j) for the minimum value of reach row of a matrix
    6 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Wietze Zijpp
 el 9 de Abr. de 2022
  
    
    
    
    
    Comentada: Voss
      
      
 el 9 de Abr. de 2022
            Suppose I have a matrix
A = 3×3
    11    13    15
    12    14    16
    32    18    21
How do I get the output (1,1) (2,1) and (1,3) which indicate the position of the minimum value of each row.
0 comentarios
Respuesta aceptada
  Voss
      
      
 el 9 de Abr. de 2022
        A=[11    13    15
    12    14    16
    32    18    21];
[minrow,idx] = min(A,[],2) % min value of each row, with column index
result = [(1:size(A,1)).' idx] % 18 is at (3,2) not (1,3)
2 comentarios
Más respuestas (1)
  Arif Hoq
      
 el 9 de Abr. de 2022
        may be you are looking for this:
A=[11    13    15
    12    14    16
    32    18    21];
mincol=min(A)  % min value of each column
minrow= min(A,[],2) % min value of each row
3 comentarios
  Arif Hoq
      
 el 9 de Abr. de 2022
				
      Editada: Arif Hoq
      
 el 9 de Abr. de 2022
  
			if you want fine the row,column of minimum of each row, then
A=[11    13    15
    12    14    16
    32    18    21];
mincol=min(A)  % min value of each column
minrow= min(A,[],2) % min value of each row
[row col]=find(ismember(A,minrow)) 
% here A(1,1)=11 >> A(2,1)=12 >> A(3,2)=18
Ver también
Categorías
				Más información sobre Creating and Concatenating Matrices en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!