Binary string to character conversion

2 vues (au cours des 30 derniers jours)
Brandon
Brandon le 20 Mar 2012
Commenté : Abirami le 14 Août 2014
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.

Réponse acceptée

Grzegorz Knor
Grzegorz Knor le 20 Mar 2012
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 commentaires
Grzegorz Knor
Grzegorz Knor le 20 Mar 2012
regexp works correctly in this case :) strrep first looks for patterns, and then replace it.
Abirami
Abirami le 14 Août 2014
hello, i need to do the same thing for a 256x256 matrix...pls help...

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by