MATLAB: Binary string to character conversion

binarycharacterconversionMATLABstring

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.

Best Answer

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')