Does "sortrows" not work with a semicolon?

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

 채택된 답변

Walter Roberson
Walter Roberson 2012년 2월 21일

1 개 추천

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

Sean de Wolski
Sean de Wolski 2012년 2월 21일
+1 good call
Doron
Doron 2012년 2월 21일
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

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Kevin Holst
Kevin Holst 2012년 2월 21일

0 개 추천

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?

카테고리

도움말 센터 및 File Exchange에서 Matrices and Arrays에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by