フィルターのクリア

Find the index of a string is structure

3 ビュー (過去 30 日間)
Eliah Verbeemen
Eliah Verbeemen 2018 年 4 月 6 日
編集済み: Eliah Verbeemen 2018 年 4 月 9 日
How can you find the index of the cell with the word dranken in a strucurearray with the fields data and textdata? I know that the word always is goind to be in the field textdata.
Thank you
  1 件のコメント
Rena Berman
Rena Berman 2018 年 4 月 9 日
(Answers Dev) Restored edit

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

採用された回答

Sergey Kasyanov
Sergey Kasyanov 2018 年 4 月 6 日
編集済み: Sergey Kasyanov 2018 年 4 月 6 日
As i understand you right, the field textdata contains cell array with some strings. Let figure that A - structure. Then if you looking for exact coincidence try this:
NumberOfCell=find(cellfun(@strcmp,A.textdata,repmat({'word'},size(A.textdata)))==1)
If textdata contain strings where you want find one word then try this:
NumberOfCell=cell2mat(cellfun(@strfind,A.textdata,repmat({'word'},size(A.textdata)),'UniformOutput',false))
  1 件のコメント
Sergey Kasyanov
Sergey Kasyanov 2018 年 4 月 6 日
編集済み: Sergey Kasyanov 2018 年 4 月 6 日
Sorry. There is mistype.
NumberOfCell=find(cellfun(@strcmp,A.textdata,repmat({'word'},size(A.textdata)))==1)

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by