How to convert a string to a 8 bit Ascii one row binary vector?
2 次查看(过去 30 天)
显示 更早的评论
Hello everyone. I have for example the string:"abcd" i want to convert it to "01100001011000100110001101100100" (see the apendded zeros). as a logical vector.
thanks!
0 个评论
采纳的回答
Azzi Abdelmalek
2016-8-17
编辑:Azzi Abdelmalek
2016-8-17
s='abcd'
p=dec2bin(double('abcd'),8)'
out=p(:)'
2 个评论
Stephen23
2016-8-17
编辑:Stephen23
2016-8-17
@Jack Day: ╞ , ╨ are not in the ASCII character set. ASCII only uses seven bits.
Those characters are in the Unicode "Box Drawing" set, which starts at 0X2500 (9472 decimal). There is no way that these can fit into seven (or even eight) bits!
To convert into a logical vector with eight bits per character, as the question requires:
reshape(dec2bin(+'abcd',8)',1,[])=='1'
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!