MATLAB: Make one column from two columns

MATLABvector

I have 2 columns, like:
A B
1 2
3 4
2 2
1 2
5 6
1 2
6 6 etc…
i would like to make 1 column from that data. I would like to take 6 rows of first column then 6 rows from second columns, next 6 rows from first and 6 rows from second and so on, so it would be
1
3
2
1
5
1
2
4
2
2
6
2
6
6
How can i do this? Can anyone help me? 🙂

Best Answer

a1=a(:,1); % a your data
a2=a(:,2);
b1=reshape(a1,6,[]);
b2=reshape(a2,6,[]);
z=zeros(6,numel(a)/6) % assuming it's divisble by 6 otherwise use rounding functions
z(:,1:2:end)=b1;
z(:,2:2:end)=b2;
Wanted = z(:)