Problem reading excel data, unknown format
3 views (last 30 days)
Show older comments
I have a sample of data from a bigger one in excel (attached), I tried with this lines of code to read the data (I need to work with the numeric values), I know they are special characters since they have a blank space before the numeric str, I tried the next but in doesn't work, any ideas?
[num,txt,raw] = xlsread('data.xls', '1', 'A1:N8'); x=(strtrim(char(txt(1,7))))% it should give '14' but still gives ' 14'
thanks
0 Comments
Accepted Answer
Star Strider
on 4 Mar 2018
It’s not a ‘normal’ space (char(32)). It’s a ‘nonbreaking’ space, (char(160)).
Use strrep to replace it with a ‘normal’ space:
txt = strrep(txt, char(160), char(32));
x=(strtrim((txt(1,6))));
Then, it works.
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!