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.

采纳的回答

Walter Roberson
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 CenterFile Exchange 中查找有关 Characters and Strings 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by