Filter löschen
Filter löschen

Help with comparing strings from cells

1 Ansicht (letzte 30 Tage)
Brandon
Brandon am 19 Jul. 2023
Kommentiert: Stephen23 am 19 Jul. 2023
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 Kommentar
Stephen23
Stephen23 am 19 Jul. 2023
"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.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 19 Jul. 2023
Bearbeitet: Fangjun Jiang am 19 Jul. 2023
A{1,5} itself is a cell. Do the following
class(A{1,5})
isequal(char(A{1,5}),'FIRING')
A{1,5}{1}

Weitere Antworten (0)

Kategorien

Mehr zu Cell Arrays finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by