Problem with find string in array
1 次查看(过去 30 天)
显示 更早的评论
Hello, i try to find mark 'bmw' in Mfg table(carbig.mat).I want to create new logic table with 1 (if string exist) or 0 to others string.
>> idx = ismember((Mfg(:,1:6)=='bmw'),[1,1,1,1,1,1],'rows')
But i have this mistake:
Error using ==
Matrix dimensions must agree.
It's my workspace:
4 个评论
the cyclist
2020-3-20
@madhan, if you type
load carbig.mat
you'll have the data. It is a file used for examples in the documentation.
采纳的回答
更多回答(1 个)
the cyclist
2020-3-20
contains(cellstr(Mfg),'bmw')
5 个评论
the cyclist
2020-3-20
This is more awkward, but will work
not(cellfun(@isempty,strfind(cellstr(Mfg),'bmw')))
I expect there is something more elegant.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!