How can I sort columns of a matrix based on the order of where the minimums occurs?

8 次查看(过去 30 天)
Hello,
I have a column matrix. I want to reorder the columns of the matrix based on the occurence of minimum in each column i.e. the first column should be the one where the minimum value occurs the first, the second where it occurs the second and so on. The attached matrix "id_min" shows this unordered arrangement, for example for column 2 the minimum value is in row 177, so it should be the first column of the new matrix, then column 39 which has the same row 177 for its minimum value, then column 38 whose minimum is in row 179 an so on. The data matrix "aa" is also attached. Your help would be highly appreciated.
Thanks

采纳的回答

Matt J
Matt J 2022-12-21
编辑:Matt J 2022-12-21
Assuming A is your matrix,
[~,imin]=min(A,[],1);
[~,is]=sort(imin);
A=A(:,is);

更多回答(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