MATLAB: Replacing a string matrix I have a set of strings is it possible to replace it by values for example in excel if i have strings as private public employed unemployed is it possible to replace values by 0.1,0.2,0.3,0.4 Best Answer [num, txt]=xlsread('Book1.xls');txt=strrep(txt,'private','0.1');txt=strrep(txt,'public','0.2');txt=strrep(txt,'unemployed','0.4');txt=strrep(txt,'employed','0.3');Val = str2double(txt); Related SolutionsMATLAB: Replacing part of a string A={'US313384RJ03(GP)','US313384RJ03(GP)'};A=strrep(A,'US','1032');A=strrep(A,'(GP)',''); MATLAB: Replace multiple values use function regexprepeg:c = {'c:\cookies.m'; ... 'c:\candy.m'; ... 'c:\calories.m'};d = regexprep(c, {'co' 'can' 'cal'}, 'N_') Related QuestionDelimiting a text file like “Text to columns”Replace columnAm I having trouble reading an ascii file in notepad that I produced using FPRINTFHow to read a matrix contain ‘?’Replacing a number in a string
Best Answer