MATLAB: Extract 2 rows each to be stored in column.

extractrows

A = [7
9
2
1
8
3];
for i=1:6
B{i}=A(1:2,:);
end
Hello everyone, I have some difficulty related with extract 'n' rows to be stored in the column. I need the rows to be like below, however, I got the result as B=[7;9] instead.
B{1}= [7
9]
B{2}= [2
1]
B{3}= [8
3]

Best Answer

Why you want a loop? You can do this in one step using reshape.
B=reshape(A,2,[]);