sort matrix by absolute value
15 ビュー (過去 30 日間)
古いコメントを表示
採用された回答
その他の回答 (1 件)
Steven Lord
2021 年 3 月 30 日
Specify the 'ComparisonMethod' name-value pair argument.
rng default
A = randi([-10 10], 5, 5)
[values, locations] = sort(A(:), 'ComparisonMethod', 'abs');
[values.'; locations.']
2 件のコメント
DGM
2021 年 3 月 30 日
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.
参考
カテゴリ
Help Center および File Exchange で Shifting and Sorting Matrices についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!