strcmp not working correctly
1 回表示 (過去 30 日間)
古いコメントを表示
I have 2 datas. behaviours_currframe.ID and label.
behaviours_currframe.ID =
3×1 cell array
{'pedestrian4'}
{'ped2' }
{'ped3' }
label =
'pedestrian4'
I am trying to do strcmp
mask = strcmp({behaviours_currframe.ID}, label);
mask
But why is the output
mask =
logical
0
Why is it 0 ? There is one item in behaviours_currframe.ID that is similar to label.
0 件のコメント
回答 (2 件)
Aiswarya Subramanian
2019 年 7 月 11 日
編集済み: madhan ravi
2019 年 7 月 11 日
Hello,
You can use the following syntax instead:
behaviours_currframe.ID = {'pedestrian4' ,'ped2' ,'ped3'};
label = 'pedestrian4';
mask = strcmp(label, behaviours_currframe.ID);
disp(mask);
Hope this helps!!
0 件のコメント
Alex Mcaulley
2019 年 7 月 11 日
編集済み: Alex Mcaulley
2019 年 7 月 11 日
The problem is in your call to strcmp:
behaviours_currframe.ID = {'pedestrian4','ped2', 'ped3'};
label = 'pedestrian4';
mask = strcmp(behaviours_currframe.ID, label)
mask =
1×3 logical array
1 0 0
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Particle Swarm についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!