Help with comparing strings from cells

조회 수: 1 (최근 30일)
Brandon
Brandon 2023년 7월 19일
댓글: Stephen23 2023년 7월 19일
Why does this come out as false?
>> A{1,5}
ans =
1×1 cell array
{'FIRING'}
>> isequal(A{1,5},'FIRING')
ans =
logical
0
  댓글 수: 1
Stephen23
Stephen23 2023년 7월 19일
"Why does this come out as false?"
Note the difference:
{'Hello'} % what you actually have
ans = 1×1 cell array
{'Hello'}
'Hello' % what you think you have
ans = 'Hello'
You have nested cell arrays, so even after curly brace indexing into the outer cell array you still have the innner cell array.

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2023년 7월 19일
편집: Fangjun Jiang 2023년 7월 19일
A{1,5} itself is a cell. Do the following
class(A{1,5})
isequal(char(A{1,5}),'FIRING')
A{1,5}{1}

추가 답변 (0개)

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by