convert bin to text
41 次查看(过去 30 天)
显示 更早的评论
I want convert binary to text for example:
A = ('abcdefghigklmnopqrstuvwxyz');
int = uint8(A);
bin = dec2bin(int);
message = char(bin);
but when execute this code the result is binary value to each character, but I want the result is the same text that converted(abcdefghigklmnopqrstuvwxyz)
0 个评论
采纳的回答
Walter Roberson
2012-1-2
message = char(bin2dec(bin));
Note: this might get you a column vector of characters. dec2bin() does not preserve the shape of the original vector anywhere, so you need to reshape() after conversion back.
2 个评论
Walter Roberson
2012-1-2
bin2dec and dec2bin are not formally defined for arrays of values. I know that bin2dec() works on arrays, but I would need to test to advise properly.
One possibility:
message = char(arrayfun(@(IDX) bin2dec(bin(IDX,:)), 1:size(bin,1)));
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!