MATLAB: Finding instances of a string withinin a structure

brainvision analyser markerseeg datafind stringstructure

Dear community,
I have structure which I would like to locate the instances of a certain string. The data is laid out as follows:
The variable is called
Markers which is 360x24 struct , with five fields.
The fields are:
ChannelNumber (double)
Description (which is a character/string)
Points (double)
Position (double)
Type (character/string)
Example:
What I'm trying to do is to find the index of all instances of 's2' in Description, so it's a string. I've tried modifying code which I've found on here, but it doesn't seem to work.
Just to give another example of the file layout, if I click on one of the structs containing S2 it looks like this in the workspace:
Markers(2, 2).Description
I know I need to use strcmp of strfind, but I just don't seem to be able to get the syntax right. Generally I never work with anything other than matrixes or cells, so this is a bit beyond my experience!
Hopefully someone can help please?
Best wishes, Joe

Best Answer

match = reshape(strcmp({Markers.Description}, 's2'), size(Markers));
Now match(i,j) is TRUE, when the struct Markers(i,j).Description is the string 's2'. If any occurrence is wanted, e.g. also "*s2*", you need:
Desc = {Markers.Description};
Desc(~cellfun('isclass', Desc, 'char')) = {''}; % Care for non-strings
matchC = reshape(strfind(Desc, 's2'), size(Markers));
match = ~cellfun('isempty', matchC);
Now match is again a logical matrix, which is TRUE, when the corresponding field contains the string 's2' anywhere.