i have 128 values in a single variable..how can separate each 8 bits?? and then i convert the each 8 bit into ascii and then convert into string??
2 次查看(过去 30 天)
显示 更早的评论
f=dec2bin(d);%i have 128 values in f
how can i separate each 8bits..and then convert into ascii and then string
0 个评论
回答(1 个)
Star Strider
2014-12-29
Since ‘f’ is already a (1x128) character array, you can create a matrix of its bytes using the rehape function:
bytes = reshape(f, 8, [])';
Each row is a consecutive byte. Again, it is already a character array, so converstion to a string is not necessary.
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!