sorting a matrix based on L2 norm of each row

7 Ansichten (letzte 30 Tage)
riad didou
riad didou am 23 Apr. 2020
Kommentiert: Ameer Hamza am 24 Apr. 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

Akzeptierte Antwort

Ameer Hamza
Ameer Hamza am 23 Apr. 2020
Bearbeitet: Ameer Hamza am 23 Apr. 2020
Try this
M = rand(9000); % random matrix for example
[~, idx] = sort(vecnorm(M, 2, 2), 'descend');
M_sorted = M(idx, :);
  2 Kommentare
riad didou
riad didou am 23 Apr. 2020
I will try it ..Thanks a lot brother
Ameer Hamza
Ameer Hamza am 24 Apr. 2020
I am glad to be of help.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (1)

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

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by