필터 지우기
필터 지우기

Arrange matrix in a ascending order

조회 수: 1 (최근 30일)
Nancy
Nancy 2011년 11월 9일
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