문제

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.

도움이 되었습니까?

해결책

Code

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

Output

01100001
01101110
01100101
01100101
01110011
01101000

다른 팁

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

str = '011000010110111001100101011001010111001101101000';
result = vec2mat(str,8);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top