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 日

0 投票

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 件)

カテゴリ

ヘルプ センター および File ExchangeShifting and Sorting Matrices についてさらに検索

質問済み:

2021 年 9 月 14 日

回答済み:

2021 年 9 月 14 日

Community Treasure Hunt

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

Start Hunting!

Translated by