>> st = struct('piece',{1,1,3,4},'food',{'cheerio','marshmallow','pizza','cereal'},'yes',{0,'food','no',0},'maybe',{'cereal',3,'yeet',6});
>> fun = @(s)any(structfun(@(m)isequal(m,'cereal'),s));
>> st(arrayfun(fun,st)) = []
st =
1x2 struct array with fields:
piece
food
yes
maybe
And checking the output:
>> st(1)
ans =
piece: 1
food: 'marshmallow'
yes: 'food'
maybe: 3
>> st(2)
ans =
piece: 3
food: 'pizza'
yes: 'no'
maybe: 'yeet'
Best Answer