What am I doing wrong with "sort()"?

What am I doing wrong with "sort()"?

Post by Daniel Maz » Fri, 06 Aug 2004 04:48:39


Suppose I creeated a 2-column array of double like this:

'\r\n')

array =

[1715x1 double] [1715x1 double]

Now I want have this array sorted by first column. When I try sort:
------------------------------
??? Error using ==> cell.sort
Input argument must be a cell array of strings.
------------------------------
Now, when I try sortrows:
------------------------------
??? Error using ==> cell.sort
Input argument must be a cell array of strings.

Error in ==> sortrows>sort_back_to_front at 134
[v,ind] = sort(x(ndx,k));

Error in ==> sortrows at 100
ndx = sort_back_to_front(x_sub);
------------------------------

What am I doing wrong?
 
 
 

What am I doing wrong with "sort()"?

Post by Stuart McG » Fri, 06 Aug 2004 05:04:08

textscan returns cell arrays. You need a numerical array to do this.


array =

[4x1 double] [4x1 double]


array2 =

4 5
2 8
3 3
1 9


sarray =

1 3
2 5
3 8
4 9