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 Exchange에서 Shifting 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