|
"Alexis Riopel" wrote in message <jsvij2$osm$1@newscl01ah.mathworks.com>...
> Hi,
>
> I have text data that looks like:
>
> ZINC00390676 CAMBD_PM_Cent_modif -8.1 0.000 0.000 -3.62724 -2.09276 -18.7599
> ZINC00390676 CAMBD_PM_Cent_modif -8.1 40.426 44.298 5.42284 7.22476 22.9496
> ZINC00390676 CAMBD_PM_Cent_modif -7.8 6.553 8.975 -0.58864 0.78112 -24.4113
> ZINC00390676 CAMBD_PM_Cent_modif -7.7 38.733 42.904 4.0946 8.61692 21.4168
> ZINC00390676 CAMBD_PM_Cent_modif -7.6 38.855 41.792 -1.07264 14.5233 18.7207
> ZINC00390676 CAMBD_PM_Cent_modif -7.6 1.824 8.358 -3.35408 -2.10728 -18.8821
> ZINC00390676 CAMBD_PM_Cent_modif -7.6 4.476 6.208 -1.67296 -1.22144 -22.1985
> ZINC00390676 CAMBD_PM_Cent_modif -7.5 35.885 40.756 -1.36496 14.0294 17.6917
>
> I actually import the data with
>
> result = textscan(fid, '%s%s%f%f%f%f%f%f');
>
> wich gives me
>
> result =
>
> Columns 1 through 5
>
> {540x1 cell} {540x1 cell} [540x1 double] [540x1 double] [540x1 double]
>
> Columns 6 through 8
>
> [540x1 double] [540x1 double] [540x1 double]
>
> I can save each of the column in a specific variable. But what I want to do is to sort all my data according to column 3. What is the most simple way to do this?
Your variable result is somewhat awkward being a 1-by- cell array. You would prefer to have it a 540-by-8 cell array with columns containing numbers and other columns containing character arrays.
If you can manage that, SORTROWS can handle cell arrays of mixed types perfectly well
A = {1 'b' 3'; 3 'a' 2 ; 2 'c' 1}
% [1] 'b' [3]
% [3] 'a' [2]
% [2] 'c' [1]
sortrows(A,2)
% [3] 'a' [2]
% [1] 'b' [3]
% [2] 'c' [1]
~ Jos
http://www.mathworks.nl/matlabcentral/fileexchange/authors/10584
|