Problem with find string in array

1 visualización (últimos 30 días)
Kostiantyn Voskoboinik
Kostiantyn Voskoboinik el 20 de Mzo. de 2020
Comentada: Kostiantyn Voskoboinik el 21 de Mzo. de 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 comentarios
the cyclist
the cyclist el 20 de Mzo. de 2020
@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 el 20 de Mzo. de 2020
Thank you the cyclist.

Iniciar sesión para comentar.

Respuesta aceptada

madhan ravi
madhan ravi el 20 de Mzo. de 2020
Wanted = ismember(cellstr(Mfg),'bmw')

Más respuestas (1)

the cyclist
the cyclist el 20 de Mzo. de 2020
contains(cellstr(Mfg),'bmw')
  5 comentarios
the cyclist
the cyclist el 20 de Mzo. de 2020
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 el 21 de Mzo. de 2020
It's work , thanks

Iniciar sesión para comentar.

Categorías

Más información sobre Data Type Conversion en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by