MATLAB: Find the index of a string is structure

find string in structure array

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

Best Answer

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))