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') Related SolutionsMATLAB: Assign header line value to variable Once you have that string, convert it to a vector like this. s = 'size=256 256 256;'; s(~isstrprop(s,'digit')) = ' '; d = str2num(s)% result% d =% 256 256 256Option 2 (update after Stephen's good point below).s = 'size=256 256 256;'; d = str2double(regexp(s,'\d+','match'))Note that this will work even if the number of dimensions in 'size' changes (size = 256 256). MATLAB: Is there a more efficient way to omit certain characters from a string without using loops One way would be newsf = regexprep(sf, '([CREP1-4]|SQ)', '') ;but what does "etc" encompass? Related QuestionInserting one character many times into a stringConvert string to numberHow to replace a certain word in a plain textProblem with a string .Convert cell to matrix
Best Answer