Problem reading excel data, unknown format
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Star Strider
2018년 3월 4일
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Spreadsheets에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!