sort matrix by absolute value
22 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
How do I sort a matrix by absolute value and display its original value with +,- sign?
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (1)
Steven Lord
am 30 Mär. 2021
Specify the 'ComparisonMethod' name-value pair argument.
rng default
A = randi([-10 10], 5, 5)
[values, locations] = sort(A(:), 'ComparisonMethod', 'abs');
[values.'; locations.']
2 Kommentare
DGM
am 30 Mär. 2021
Do you know about when that option was introduced? I'm guessing it was some time around 2018, but release notes are vague and I only know it's not in R2015b.
Siehe auch
Kategorien
Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!