필터 지우기
필터 지우기

sort rows of a matrix based on their maximum value

조회 수: 10 (최근 30일)
pavlos
pavlos 2013년 9월 11일
Hello,
Consider a 100x10 matrix.
Each 1x10 row has a maximum value.
How can I sort the rows of the matrix in ascending order based only on their maximum value?
Thank you very much.
Best,
Pavlos

채택된 답변

Jan
Jan 2013년 9월 11일
A = rand(100, 10);
maxA = max(A, [], 2);
[dummy, index] = sort(maxA);
B = A(index, :);
  댓글 수: 1
Simon
Simon 2013년 9월 11일
Great! Better solution than mine!
Side note: you may use "~" instead of "dummy".

댓글을 달려면 로그인하십시오.

추가 답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 11일
편집: Azzi Abdelmalek 2013년 9월 11일
Edit2
[ii,ii]=sort(max(A'))
BB=A(ii,:)

Simon
Simon 2013년 9월 11일
A=randi(100,10,5);
for n = 1:size(A, 1)
B(n,:) = sort(A(n,:));
end

카테고리

Help CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by