MATLAB: Searching for group of letters in a structure or character string

matsharkstringsstructureswireshark

Hi all,
I am working with a structure that contains various pieces of mixed data and having trouble sifting through it to find necessary pieces of info. For example, Structure(1).field contains eth:ip:udp:dns and Structure(169).field contains eth:ip:tcp.
I would like to efficiently find, for example, all elements that contain tcp.
If anyone could help out I would really appreciate it.
Thanks, Adam

Best Answer

Suppose your structure is:
S(1).field = 'eth:ip:udp:dns';
S(2).field = 'eth:ip:tcp';
S(3).field = 'eth:ip';
idx = ~cellfun('isempty',strfind({S.field},'tcp'));
S(idx)