| Labfans是一个针对大学生、工程师和科研工作者的技术社区。 | 论坛首页 | 联系我们(Contact Us) |
![]() |
|
|
#1 |
|
初级会员
注册日期: 2008-08-14
年龄: 37
帖子: 17
声望力: 18 ![]() |
我知道能用 sort排一个矩阵的序,但是只能是对某一列,我现在想按其中一列排序,然后其他的列与排序 的列的相对位置不变,怎么半啊???有没这样的命令??没有该怎么做呢??
比如要对【2,3,1;4,5,6】按第一列排序后是【1,2,3;6,4,5】 谢谢大家啊!! |
|
|
|
|
|
#2 |
|
普通会员
注册日期: 2008-08-17
年龄: 36
帖子: 70
声望力: 21 ![]() ![]() |
很简单,你复制代码运行下:
代码:
a=[2,3,1;4,5,6]; [b,pos]=sort(a(1,:)); a=a(:,pos); a |
|
|
|
|
|
#3 |
|
初级会员
注册日期: 2008-08-14
年龄: 37
帖子: 17
声望力: 18 ![]() |
不胜感激!!!:redface:
|
|
|
|
|
|
#4 |
|
初级会员
注册日期: 2008-12-26
年龄: 46
帖子: 2
声望力: 0 ![]() |
我也学习了!
|
|
|
|
|
|
#5 |
|
普通会员
注册日期: 2007-08-07
帖子: 64
声望力: 21 ![]() |
用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. |
|
|
|
![]() |
|
|
相似的主题
|
||||
| 主题 | 主题作者 | 版面 | 回复 | 最后发表 |
| [求助]图像像素间的相关性? | hippo613 | MATLAB论坛 | 1 | 2009-01-09 08:36 |
| [分享]计算方法matlab程序 | guofeng0108 | MATLAB论坛 | 2 | 2008-11-18 03:43 |
| [求助]一个很简单的问题,可是就是不知道问题出在哪儿? | pikky | MATLAB论坛 | 6 | 2008-11-17 18:21 |
| 关于采样 | tomasso | MATLAB论坛 | 0 | 2008-11-13 10:04 |
| 求助!!!一道求响应的题目 | jin429431378 | MATLAB论坛 | 0 | 2008-11-06 09:40 |