Binary string to character conversion
1 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
采纳的回答
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
2012-3-20
regexp works correctly in this case :) strrep first looks for patterns, and then replace it.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Characters and Strings 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!