Reading text using xlsread in a loop inquiry
조회 수: 6 (최근 30일)
이전 댓글 표시
I am trying to import text data from an excel file. There are only 3 letters which are possible, A, B, or C.
The only method I have had success with in importing the data in a loop is through something along the lines of:
[Data Text] = xlsread('Data.xlsx',char(Sites(i)),'D:H');
FinalText{:,i} = Text
However, this gives me some sort of dimensions of {1x55}, and individual points are {1x1}(1,1), {1x1}(2,1), etc. Now I want to test whether this data is either 'A', 'B', or 'C'. So I used the following code:
Quality{1,1}(1,1) = 'C'
Which gave me the error:
Conversion to cell from char is not possible.
Any help with getting the data into a format to test whether they are 'A', 'B', or 'C' would be greatly appreciated.
댓글 수: 0
채택된 답변
Walter Roberson
2016년 3월 31일
[tf, idx] = ismember(Text, {'A', 'B', 'C'});
The places where tf is true will then be the places that matched one of those three, and the corresponding idx value will tell you which of those three it matched; for locations that did not match, idx would be 0. So idx will be 0 for non-matches, 1 for A, 2 for B, 3 for C.
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Characters and Strings에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!