MATLAB Answers


how to sort the rows of a matrix?

Asked by Stef
on 12 Aug 2018
Latest activity Commented on by Walter Roberson
on 12 Aug 2018
I have a matrix RG_table with two columns. I want to sort the rows of the matrix in descending order depending on column 2. Column 2 has values which are non integers. I tried it with sortrows, but I get this error:
Column sorting vector must contain integers with absolute value between 1 and the number of columns in the first argument.
score_sort = sortrows(RG_table, 2, 'descend');
Does anybody know what to do?


I am running it on a server where I get the error. If I run it locally on my PC I do not get the error. Does anybody know why?
Well, no...we have no way to know any such thing.
One guess would be the data on the server isn't the same as that locally...
Again without much more detail and context we're shooting in the dark here.
At a minimum, put
whos RG_table
in the function/script before executing the sortrows line on each platform. That will at least be a chance at figuring out what it is you're looking at.
Basically the message is telling you that the table is either empty or has only 1 column.

Sign in to comment.


0 Answers