Help with comparing strings from cells

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 comentario

"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.

Iniciar sesión para comentar.

 Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 19 de Jul. de 2023
Editada: Fangjun Jiang el 19 de Jul. de 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}

Más respuestas (0)

Categorías

Más información sobre Characters and Strings en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 19 de Jul. de 2023

Comentada:

el 19 de Jul. de 2023

Community Treasure Hunt

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

Start Hunting!

Translated by