Binary string to character conversion

1 回表示 (過去 30 日間)
Brandon
Brandon 2012 年 3 月 20 日
コメント済み: Abirami 2014 年 8 月 14 日
Hello, If I have a string, S = 001000110111 Given:
a = 0
b = 10
c = 110
d = 111
I need to convert the string using that key.
So converted_S = aabaacd
How can I do this? Thanks.

採用された回答

Grzegorz Knor
Grzegorz Knor 2012 年 3 月 20 日
S = '001000110111';
a = '0';
b = '10';
c = '110';
d = '111';
S = strrep(S,d,'d');
S = strrep(S,c,'c');
S = strrep(S,b,'b');
S = strrep(S,a,'a')
  5 件のコメント
Grzegorz Knor
Grzegorz Knor 2012 年 3 月 20 日
regexp works correctly in this case :) strrep first looks for patterns, and then replace it.
Abirami
Abirami 2014 年 8 月 14 日
hello, i need to do the same thing for a 256x256 matrix...pls help...

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by