convert bin to text

37 ビュー (過去 30 日間)
Aseel H
Aseel H 2012 年 1 月 2 日
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)

採用された回答

Walter Roberson
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 件のコメント
Aseel H
Aseel H 2012 年 1 月 2 日
Thanks Walter,
but when execute
message = char(bin2dec(bin));
on long text, I have this error
"Binary string must be 52 bits or less".
Walter Roberson
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 ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by