How to change string to number in excel file?
4 views (last 30 days)
Show older comments
Hi,
I have an excel file that contains string (y and n). I read the file using xlsread. Now I want to replace all the y's with 1 and all the n's with 0. How can I do that?
0 Comments
Accepted Answer
Jan
on 14 Feb 2013
data = {'y', 'y', 'n', 'y'};
value = nan(size(data));
value(strcmp(data, 'y')) = 1;
value(strcmp(data, 'n')) = 0;
0 Comments
More Answers (0)
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!