Lexicographic ranking of vectors
显示 更早的评论
Hello everyone!
I have the following problem. I have an Nx2^N matrix of zeros and ones and I want to rearrange the columns as follows. First, in ascending order according to the column sum. Second, I want all columns that give the same column sum to be ordered AS VECTORS from greatest to smallest according to the lexicographical order (according to which vector x is greater than or equal to vector y if there is some j<=N such that x(i)=y(i) for all i<j (if any) and x(j)>y(j)).
For example, if the original matrix is:
A=[0 0 0 0 1 1 1 1;
0 0 1 1 0 0 1 1;
0 1 0 1 0 1 0 1]
(for N=3) I want to obtain:
B=[0 1 0 0 1 1 0 1;
0 0 1 0 1 0 1 1;
0 0 0 1 0 1 1 1]
Thanks! Alejandro
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!