Arrange matrix in a ascending order

2 次查看(过去 30 天)
Hi Guys,
If I have a matrix say of the following form
X = 42.5123 42.3975 42.2375 42.1167 42.1354 41.8895
67.7294 67.6697 67.6345 67.5530 67.5784 67.4758
I want to arrange it in such a way that the if the last element in the first row is the smallest element (like the eg above), I want to reverse the order completely.
X= 41.8895 42.1354 42.1167 42.2375 42.3975 42.5123
67.4758 67.5784 67.5530 67.6345 67.6697 67.7294
You can see that the order is just reversed. Can anyone tell me how I can accomplish this in MATLAB.
Thanks, Nancy

采纳的回答

Walter Roberson
Walter Roberson 2011-11-9
If you know that you are reversing from side to side, then just
newX = fliplr(X);
Otherwise,
[sortX, xidx] = sort(X(1,:));
newX = X(:,xidx);
  1 个评论
chengxuan yu
chengxuan yu 2011-11-9
Just use the function 'fliplr' that above could be the best choose!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Logical 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by