MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [求助]关于matlab排序的问题! (https://www.labfans.com/bbs/showthread.php?t=4148)

叉叉 2008-08-17 21:21

[求助]关于matlab排序的问题!
 
我知道能用 sort排一个矩阵的序,但是只能是对某一列,我现在想按其中一列排序,然后其他的列与排序 的列的相对位置不变,怎么半啊???有没这样的命令??没有该怎么做呢??

比如要对【2,3,1;4,5,6】按第一列排序后是【1,2,3;6,4,5】


谢谢大家啊!!

pslpsl 2008-08-20 01:34

回复: 求助!急啊!关于matlab排序的问题!
 
很简单,你复制代码运行下:

[CODE]a=[2,3,1;4,5,6];
[b,pos]=sort(a(1,:));
a=a(:,pos);
a[/CODE]

叉叉 2008-08-20 17:39

回复: [求助]matlab多项式的问题
 
不胜感激!!!:redface:

Mike 2008-12-26 10:38

回复: [求助]关于matlab排序的问题!
 
我也学习了!

xiezhh 2008-12-27 16:01

回复: [求助]关于matlab排序的问题!
 
[SIZE="5"]用sortrows函数,自己看帮助,

B = sortrows(A,column) sorts the matrix based on the columns specified in the vector column. If an element of column is positive, the MATLAB? software sorts the corresponding column of matrix A in ascending order; if an element of column is negative, MATLAB sorts the corresponding column in descending order. For example, sortrows(A,[2 -3]) sorts the rows of A first in ascending order for the second column, and then by descending order for the third column.[/SIZE]


所有时间均为北京时间。现在的时间是 12:20

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.