How can I insert a sequental columns in a matrix with a lag of three columns?
    3 views (last 30 days)
  
       Show older comments
    
    Ekaterina Serikova
 on 4 Jul 2016
  
    
    
    
    
    Commented: Ekaterina Serikova
 on 5 Jul 2016
            Dear all,
I have a two-dimensional matrix A, which contains 914 columns. I would like to create a matrix B and insert every columns from A, so that
Column 1 from A goes to column 1 in B
column 2 from A goes to column 4 in B
column 3 from A goes to column 7 in B...and so on
I tried that code, but it gives me an error:
B=nan(size(A,1),size(A,2)*3);
for i=4:3:size(B,2);
    for ii=1:size(A,2);
    data(:,i)=A(:,i-2*ii);
    end
end
0 Comments
Accepted Answer
  Azzi Abdelmalek
      
      
 on 4 Jul 2016
         A=randi(9,4,3) 
n=size(A,2)
B=nan(size(A,1),n*3)
idx=1:3:size(B,2) 
B(:,idx)=A
More Answers (0)
See Also
Categories
				Find more on Elementary Math 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!
