sorting and unsorting ?

조회 수: 13 (최근 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 CenterFile Exchange에서 Shifting and Sorting Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by