From: Jos (10584) on 26 Feb 2010 08:27 Rune Allnor <allnor(a)tele.ntnu.no> wrote in message <af2e7889-0795-4d3e-b9cc-650a01628d0e(a)d27g2000yqf.googlegroups.com>... * snip > If you want this for real, the most efficient way to > swap columns is this: > > B=A; > B(:,1)=A(:,2); > B(:,2)=A(:,1); or swap in a single statement B = A ; % work on a copy B(:,[1 2]) = B(:,[2 1]) % swap using right-hand indexing B(:,[2 1]) = B(:,[1 2]) % swap (back) using left hand indexing hth Jos
From: Matt Dunham on 1 Mar 2010 13:11
"BHARATH " <bhushabhusha(a)gmail.com> wrote in message <hm2h9c$76q$1(a)fred.mathworks.com>... > hi > > i have a matrix , A. > i will multiply with permutation matrix for interchange of columns. > > i have to know which columns have been changed by their position value. > i.e, if A's column position are 1 2 3 4 for orginal one > > and for permutated one as 3 4 1 2... > > please help me in indexing.... Try using the find function on the permutation matrix. |