sorting a matrix based on L2 norm of each row

9 次查看(过去 30 天)
Hello all
Please how to code; descendent sorting a matrix C(9000x9000) based on L2 norm of each row then reconstruct a new ranked matrix.
Thanks in advance

采纳的回答

Ameer Hamza
Ameer Hamza 2020-4-23
编辑:Ameer Hamza 2020-4-23
Try this
M = rand(9000); % random matrix for example
[~, idx] = sort(vecnorm(M, 2, 2), 'descend');
M_sorted = M(idx, :);

更多回答(1 个)

David Hill
David Hill 2020-4-23
[~,idx]=sortrows(vecnorm(C,2,2));
C=C(idx,:);

类别

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