Help with comparing strings from cells

4 ビュー (過去 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 Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by