Pergunta

I have a long binary string which i want to convert to n*8 dimension matrix in matlab.

I tried using reshape() but it works column wise and i am not able to obtain the output as it works column wise and not row wise.

i want to convert this:

011000010110111001100101011001010111001101101000

to this:

01100001

01101110

01100101

01100101

01110011

01101000

Is there any in-built method to work row-wise or is there any workaround to this silly issue? PS: I tried using "transpose" but it gives me a 8*6 matrix which i do not desire.

Foi útil?

Solução

Code

str = '011000010110111001100101011001010111001101101000';
reshape(str',8,[])'

Output

01100001
01101110
01100101
01100101
01110011
01101000

Outras dicas

If you have the Communications toolbox, you can also use vec2mat, which works row-wise:

str = '011000010110111001100101011001010111001101101000';
result = vec2mat(str,8);
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top