sorting and unsorting ?

4 visualizaciones (últimos 30 días)
Muhammad
Muhammad el 14 de Sept. de 2021
Respondida: Image Analyst el 14 de Sept. de 2021
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

Respuesta aceptada

Image Analyst
Image Analyst el 14 de Sept. de 2021
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

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by