Reading text using xlsread in a loop inquiry

6 ビュー (過去 30 日間)
Micheal Simpson
Micheal Simpson 2016 年 3 月 31 日
コメント済み: Micheal Simpson 2016 年 3 月 31 日
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.
  1 件のコメント
Micheal Simpson
Micheal Simpson 2016 年 3 月 31 日
Brilliant!
Thank you for your help!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by