Replacing a string

18 views (last 30 days)
kash
kash on 13 Feb 2012
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

Accepted Answer

TAB
TAB on 13 Feb 2012
[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);

More Answers (0)

Categories

Find more on Characters and Strings in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!