sorting a matrix based on L2 norm of each row

9 views (last 30 days)
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

Accepted Answer

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

More Answers (1)

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

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!