Problem with find string in array

1 回表示 (過去 30 日間)
Kostiantyn Voskoboinik
Kostiantyn Voskoboinik 2020 年 3 月 20 日
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
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.
madhan ravi
madhan ravi 2020 年 3 月 20 日
Thank you the cyclist.

サインインしてコメントする。

採用された回答

madhan ravi
madhan ravi 2020 年 3 月 20 日
Wanted = ismember(cellstr(Mfg),'bmw')
  1 件のコメント
Kostiantyn Voskoboinik
Kostiantyn Voskoboinik 2020 年 3 月 21 日
Thanks,it's work

サインインしてコメントする。

その他の回答 (1 件)

the cyclist
the cyclist 2020 年 3 月 20 日
contains(cellstr(Mfg),'bmw')
  5 件のコメント
the cyclist
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.
Kostiantyn Voskoboinik
Kostiantyn Voskoboinik 2020 年 3 月 21 日
It's work , thanks

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by