Problem with find string in array
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kostiantyn Voskoboinik
le 20 Mar 2020
Commenté : Kostiantyn Voskoboinik
le 21 Mar 2020
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 commentaires
the cyclist
le 20 Mar 2020
@madhan, if you type
load carbig.mat
you'll have the data. It is a file used for examples in the documentation.
Réponse acceptée
Plus de réponses (1)
the cyclist
le 20 Mar 2020
contains(cellstr(Mfg),'bmw')
5 commentaires
the cyclist
le 20 Mar 2020
This is more awkward, but will work
not(cellfun(@isempty,strfind(cellstr(Mfg),'bmw')))
I expect there is something more elegant.
Voir également
Catégories
En savoir plus sur Data Type Conversion dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!