Search for a specific string in a dataset

2 ビュー (過去 30 日間)
Nurul Ain
Nurul Ain 2014 年 3 月 19 日
コメント済み: Nurul Ain 2014 年 3 月 19 日
Hi all,
I have a dataset (SDEV) with 4 columns (ID,Name,ImageFile,Tel). I try to create a new dataset with only ID and Name for all data with ImageFile contains only word 'fixed'. My ImageFile contains very long string like 'document/test/fixed/image/001_controlled', 'document/test/shaked/image/001_controlled', etc.
I code like this:
load SDev;
h1 =SDev(SDev.ID==3 & SDev.ImageFile=='.*fixed*',{'ID' 'Name'})
and it gave me error: Undefined function 'eq' for input arguments of type 'cell'.
Thank you in advance.

採用された回答

Image Analyst
Image Analyst 2014 年 3 月 19 日
It probably doesn't like this SDev.ImageFile=='.*fixed*'
ImageFile might be a cell. And you should use strcmpi() instead o f== for comparing strings
strcmpi(char(SDev.ImageFile), '.*fixed*')
  1 件のコメント
Nurul Ain
Nurul Ain 2014 年 3 月 19 日
Hi Image Analyst,
Thank you for your reply. I made correction to my code:
h1 =SDev(SDev.ID==3 & strcmpi(char(SDev.ImageFile), '.*fixed*'),{'ID' 'Name'})
and it return me:
h1 = empty 0-by-2 dataset

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeConvert Image Type についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by