MATLAB: Hi everyone, can you help me to solve following program

interleaver

A= [1 2 3, 4 5 6, 7 8 9]
B= [2 2 2, 2 2 2, 2 2 2] C matrix should be in follwoing form
C=
1 2 2
4 2 2
7 5 3
2 8 6
2 2 9
How can I get this resultant matrix C? Thanks

Best Answer

>> A = [1,2,3;4,5,6;7,8,9];
>> B = 2*ones(3);
>> C = [A;B];
>> C = reshape(C(1:end-3),[],3)
C =
1 2 2
4 2 2
7 5 3
2 8 6
2 2 9