Does "sortrows" not work with a semicolon?

1 visualización (últimos 30 días)
Doron
Doron el 21 de Feb. de 2012
Could someone clarify this issue I am having?
I tried to sort the rows of a matrix by the first column (in descending order)...
sortrows(P, -1) % works fine
But, for some reason:
sortrows(P, -1); % does not work!
Is this a known issue?
D Howard

Respuesta aceptada

Walter Roberson
Walter Roberson el 21 de Feb. de 2012
Remember, sortrows(P,-1); would sort the rows and then would throw away the results because you did not write them to a variable.
  2 comentarios
Sean de Wolski
Sean de Wolski el 21 de Feb. de 2012
+1 good call
Doron
Doron el 21 de Feb. de 2012
Well spotted, Walter & Sean.
It does work, but it throws away the result, of course.
I guess I was "doing in Matlab and thinking in Excel"
D Howard

Iniciar sesión para comentar.

Más respuestas (1)

Kevin Holst
Kevin Holst el 21 de Feb. de 2012
Works fine for me. I did this:
a = magic(5);
b = sortrows(a,-1);
When you say, does not work, do you mean it gives you an error, or it does not sort properly?

Categorías

Más información sobre Matrices and Arrays 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!

Translated by