필터 지우기
필터 지우기

Using the text from the excel data imported

조회 수: 1 (최근 30일)
Mark
Mark 2013년 3월 16일
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?

채택된 답변

Image Analyst
Image Analyst 2013년 3월 16일
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"
  댓글 수: 3
Image Analyst
Image Analyst 2013년 3월 16일
Then, mark as Accepted.
Mark
Mark 2013년 3월 16일
Mark marked as Accepted. Sorry about that!

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 3월 16일
Use
if strcmp(word1,'ABC')

카테고리

Help CenterFile Exchange에서 Spreadsheets에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by