Effacer les filtres
Effacer les filtres

Find the index of a string is structure

3 vues (au cours des 30 derniers jours)
Eliah Verbeemen
Eliah Verbeemen le 6 Avr 2018
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 commentaire
Rena Berman
Rena Berman le 9 Avr 2018
(Answers Dev) Restored edit

Connectez-vous pour commenter.

Réponse acceptée

Sergey Kasyanov
Sergey Kasyanov le 6 Avr 2018
Modifié(e) : Sergey Kasyanov le 6 Avr 2018
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 commentaire
Sergey Kasyanov
Sergey Kasyanov le 6 Avr 2018
Modifié(e) : Sergey Kasyanov le 6 Avr 2018
Sorry. There is mistype.
NumberOfCell=find(cellfun(@strcmp,A.textdata,repmat({'word'},size(A.textdata)))==1)

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Characters and Strings dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by