Equalities between strings and strings in cell arrays
2 ビュー (過去 30 日間)
古いコメントを表示
I am trying to create a piece of code that checks the string value in a cell array and then assigns a numerical value to another cell based on the identity of that string.
However, no matter what equality function I try to use, I always get an error back or an inequality when both values are obviously the same. Can someone explain what is going on to me?
Here's the hunk of code that I am having trouble with. If the cell array 'C' and string 'C' are the same then I should get an output of 1.
>> tbl{row,2}(1)
ans =
'C'
>> isequal(tbl{row,2}(1),'C') == 1
ans =
0
0 件のコメント
回答 (2 件)
Andrei Bobrov
2012 年 11 月 21 日
編集済み: Andrei Bobrov
2012 年 11 月 21 日
try
isequal(tbl{row,2}{1},'C')
or
isequal(tbl{row,2}(1),{'C'})
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Characters and Strings についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!