Using the text from the excel data imported

4 views (last 30 days)
I imported an Excel file with text. I named this data data_with_text. When I use
>> word1=data_with_text(1,1)
I get:
word1 = 'ABC'
Ideally I could run something like this using word1:
>> if word1=='ABC'
x=1
else
x=0
end
However, this does not work and I get this error,
Undefined function 'eq' for input arguments of type 'cell'.
which I presume comes from the apostrophes because word1='ABC' and not plain ABC without the apostophes
Is there any way around this?

Accepted Answer

Image Analyst
Image Analyst on 16 Mar 2013
It's a cell. Try converting it to a character string:
word1 = char(data_with_text(1,1))
Or maybe you could do it this way too:
word1=data_with_text{1,1} % {} mean "contents of the cell"

More Answers (1)

Azzi Abdelmalek
Azzi Abdelmalek on 16 Mar 2013
Use
if strcmp(word1,'ABC')

Community Treasure Hunt

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

Start Hunting!