Reading text using xlsread in a loop inquiry

6 visualizaciones (últimos 30 días)
Micheal Simpson
Micheal Simpson el 31 de Mzo. de 2016
Comentada: Micheal Simpson el 31 de Mzo. de 2016
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.

Respuesta aceptada

Walter Roberson
Walter Roberson el 31 de Mzo. de 2016
[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.

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by