sorting and unsorting ?

9 ビュー (過去 30 日間)
Muhammad
Muhammad 2021 年 9 月 14 日
回答済み: Image Analyst 2021 年 9 月 14 日
clc
clear all
a=magic(3)
[b,ind]=sort(a,1,'descend')
c(ind)=b;
i sorted the matrix but i want back the orignal matix a how i can do it

採用された回答

Image Analyst
Image Analyst 2021 年 9 月 14 日
Try this:
a = magic(3)
[b, sortOrder] = sort(a, 1, 'descend')
c = zeros(size(b));
for col = 1 : size(b, 2)
c(:, col) = b(sortOrder(:, col), col);
end
c

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeShifting and Sorting Matrices についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by