MATLAB Answers


change column in matrix

Asked by Rica
on 7 Dec 2012


is it possible in matlab to change coluns:

 A=[a1 a2 a3 a4.......a2250],a1...a2250 are arrays oth size(30*1).
 i want to get this matrix B=[a1 a75 a150.... a2 a76....a3 a77..... ].
 that means i have a step of 74

i wish you could help thank you

  1 Comment

if you step size is 74..the matrix will be B=[a1 a75 a149 a223...] like this only.. check is your question is right?


No products are associated with this question.

2 Answers

Answer by Andrei Bobrov
on 7 Dec 2012
Edited by Andrei Bobrov
on 7 Dec 2012

B = reshape(permute(reshape(A,size(A,1),75,[]),[1 3 2]),size(A,1),[]);


s = size(A,2);
B = A(:,bsxfun(@plus,1:75:s,(0:(s/75-1))')');


B = A(:,reshepe(1:size(A,2),75,[])');


Answer by Muruganandham Subramanian on 7 Dec 2012
Edited by Muruganandham Subramanian on 7 Dec 2012

d=reshape(a,[75 30]);


Join the 15-year community celebration.

Play games and win prizes!

Learn more
Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

MATLAB Academy

New to MATLAB?

Learn MATLAB today!