MATLAB: How to generate a Matrix of specific rows and columns using loop

loopMATLABmatrix

I have a block of 20 Bits
A=[1 0 0 1 0 1 0 1 0 0 0 1 0 1 0 1 0 0 1 0];
How can I generate a Matrix of ie 5 Rows and 4 columns from a single row using loop? B=(4,5)? Thanks in Advance.

Best Answer

It's really not clear what sort of matrix you want to create from your vector. Maybe you just want to reshape it?
B = reshape(A, 5, []) %reshape A as 5 rows and as many columns as necessary