Reading text using xlsread in a loop inquiry
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Micheal Simpson
il 31 Mar 2016
Commentato: Micheal Simpson
il 31 Mar 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.
0 Commenti
Risposta accettata
Walter Roberson
il 31 Mar 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.
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Characters and Strings in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!