MATLAB: How to split this

MATLABmatrixsplit

I have M as a result of another function.
and I have to split M like C automatically…
I want to split it every 16 bits.
M => input split function => output C
M = '01100001011000100110001110000000000000000000000000000000000000000000000000000000'
????
C = {'0110000101100010'; '0110001110000000'; '0000000000000000'; '0000000000000000';'0000000000000000';}
how to make it? I'm stuck on this problem…
can you help me?

Best Answer

C = reshape(M, 16,[])'
C =
5×16 char array
'0110000101100010'
'0110001110000000'
'0000000000000000'
'0000000000000000'
'0000000000000000'
If you need it to end up as a cell array or chars, you can wrap it in cellstr:
C = cellstr(reshape(M, 16,[])')
C =
5×1 cell array
{'0110000101100010'}
{'0110001110000000'}
{'0000000000000000'}
{'0000000000000000'}
{'0000000000000000'}
Related Question