permuting one matrix w.r.t. another matrix
Show older comments
I have two large matrices a and b. for instance
a=[1 2 3;4 5 6; 7 8 9; 10 11 12];
b=[1 3 2; 2 1 3; 3 2 1; 3 1 2];
how to get the matrix a in the form:
a = [1 3 2; 5 4 6; 9 8 7; 12 10 11]
This is actually the permutation of matrix a w.r.t. matrix b.
How to achieve this goal in matlab?
Accepted Answer
More Answers (1)
Walter Roberson
on 30 Dec 2018
a((b-1) * size(a,1) + (1:size(a,1)).')
This requires R2016b or later.
1 Comment
tanveer haq
on 30 Dec 2018
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!