sorting a matrix based on L2 norm of each row

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

 Réponse acceptée

Ameer Hamza
Ameer Hamza le 23 Avr 2020
Modifié(e) : Ameer Hamza le 23 Avr 2020
Try this
M = rand(9000); % random matrix for example
[~, idx] = sort(vecnorm(M, 2, 2), 'descend');
M_sorted = M(idx, :);

2 commentaires

riad didou
riad didou le 23 Avr 2020
I will try it ..Thanks a lot brother
Ameer Hamza
Ameer Hamza le 24 Avr 2020
I am glad to be of help.

Connectez-vous pour commenter.

Plus de réponses (1)

Catégories

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by