Combine two columns into one by first two rows A two rows B and so on
Show older comments
Hi, I want to combine two columns A and B (both 4x1) into one column C by using first the first two rows of A, then the first two rows of B, then the second two rows of A and so on.
A=[1,2,3,4]';
B=[-5,-6,-7,-8]';
I tried
N = size(A,1)+size(B,1) ;
C = zeros(N,1) ;
C(1:2:end) = A ;
C(2:2:end) = B ;
But not working.
Answer should be
C=[1;2;-5;-6;3;4;-7;-8]
Accepted Answer
More Answers (0)
Categories
Find more on Simscape Fluids 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!