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

 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, :);

2 Commenti

I will try it ..Thanks a lot brother
I am glad to be of help.

Accedi per commentare.

Più risposte (1)

Categorie

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by