sort rows of a matrix based on their maximum value

4 次查看(过去 30 天)
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, :);

更多回答(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