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 Kommentare

Stephen23
Stephen23 am 20 Mär. 2020
First convert the character matrix to a cell array of strings or to a string array without leading/trailing space characters and then use strcmpi.
madhan ravi
madhan ravi am 20 Mär. 2020
Would you attach a sample file ?
@madhan, if you type
load carbig.mat
you'll have the data. It is a file used for examples in the documentation.
madhan ravi
madhan ravi am 20 Mär. 2020
Thank you the cyclist.

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

madhan ravi
madhan ravi am 20 Mär. 2020

1 Stimme

Wanted = ismember(cellstr(Mfg),'bmw')

Weitere Antworten (1)

the cyclist
the cyclist am 20 Mär. 2020

1 Stimme

contains(cellstr(Mfg),'bmw')

5 Kommentare

Kostiantyn Voskoboinik
Kostiantyn Voskoboinik am 20 Mär. 2020
Undefined function 'contains' for input arguments of type 'cell'.
the cyclist
the cyclist am 20 Mär. 2020
Do you have an older version of MATLAB? The contains function was introduced in R2016b.
Kostiantyn Voskoboinik
Kostiantyn Voskoboinik am 20 Mär. 2020
Yes, i have 2015b
This is more awkward, but will work
not(cellfun(@isempty,strfind(cellstr(Mfg),'bmw')))
I expect there is something more elegant.
Kostiantyn Voskoboinik
Kostiantyn Voskoboinik am 21 Mär. 2020
It's work , thanks

Melden Sie sich an, um zu kommentieren.

Kategorien

Community Treasure Hunt

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

Start Hunting!

Translated by