HOW CAN I SORTED MY MATRIX DESCEND
    2 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    ali hadjer
 el 22 de Nov. de 2015
  
    
    
    
    
    Comentada: ali hadjer
 el 22 de Nov. de 2015
            I HAVE A MATRIX M=[ 1 2 3 4 5 ;1 20 54 6 40] I WANT TO SORT MY MATRIX WITHIN THE SECOND COLON  WITH ASCENDING WAY TO OBTEIND THIS RESULT :
M=[3 5 2 4 1;54 40 20 6 1]
HOW CAN I DO
0 comentarios
Respuesta aceptada
  Andrei Bobrov
      
      
 el 22 de Nov. de 2015
        
      Editada: Andrei Bobrov
      
      
 el 22 de Nov. de 2015
  
      M=[ 1 2 3 4 5 ;1 20 54 6 40];
[~,ii] = sort(M(2,:),'descend');
out = M(:,ii);
or
out = sortrows(M',-2)';
Más respuestas (0)
Ver también
Categorías
				Más información sobre Shifting and Sorting 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!