sort matrix by absolute value
Ältere Kommentare anzeigen
How do I sort a matrix by absolute value and display its original value with +,- sign?
Akzeptierte Antwort
Weitere Antworten (1)
Specify the 'ComparisonMethod' name-value pair argument.
rng default
A = randi([-10 10], 5, 5)
[values, locations] = sort(A(:), 'ComparisonMethod', 'abs');
[values.'; locations.']
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!