sorting a matrix based on L2 norm of each row

5 vues (au cours des 30 derniers jours)
riad didou
riad didou le 23 Avr 2020
Commenté : Ameer Hamza le 24 Avr 2020
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)

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

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by