Azzera filtri
Azzera filtri

sorting a matrix based on L2 norm of each row

2 visualizzazioni (ultimi 30 giorni)
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

Risposta accettata

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

Più risposte (1)

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

Categorie

Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by