sorting a matrix

4 visualizaciones (últimos 30 días)
zamrud fathima
zamrud fathima el 1 de Mzo. de 2011
Respected Sir/Madam,
I have taken some 3*3 matrix for that I had assigned a variable for each row. I had used ‘sort’ command for sorting either in increasing or deceasing mode for only one row. My question is when I sort one row then the corresponding rows in that column should come but the remaining rows should not be sorted. Can you please clarify it to me?
With regards Fathima
  1 comentario
Jan
Jan el 1 de Mzo. de 2011
If you assigned the single rows to variables, using SORT affects the sepcified variable only. Therefore I do not understand the question. Please post the code with some example values as input and wanted output.

Iniciar sesión para comentar.

Respuestas (1)

Oleg Komarov
Oleg Komarov el 1 de Mzo. de 2011
To sort just a single row:
A = [1 2 3
4 5 6
7 8 9];
% Sort only first row
A(1,:) = sort(A(1,:),'descend');
Oleg

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by