Find a word in structure

1 回表示 (過去 30 日間)
Erik Verdijk
Erik Verdijk 2018 年 3 月 30 日
コメント済み: Erik Verdijk 2018 年 3 月 30 日
Ik like to find a word (example:cat)in a structure field (by example: structureA.field1). How can you do that?

回答 (1 件)

Birdman
Birdman 2018 年 3 月 30 日
編集済み: Birdman 2018 年 3 月 30 日
One approach:
structureA=struct;
structureA.field1="cat";
strfind(structureA.field1,"cat")
It will return 1 since the number of cat word in second argument of strfind function is 1.
  5 件のコメント
Stephen23
Stephen23 2018 年 3 月 30 日
@Erik Verdijk: What version of MATLAB are you using?
Erik Verdijk
Erik Verdijk 2018 年 3 月 30 日
R2016a

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

カテゴリ

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