MATLAB: How delete empty fields in a struct

emptyfieldstruct

Hi! I have a struct (attached) and I want to delete the empty field, how can I do?

Best Answer

out = {t(~cellfun(@isempty,{t.places})).places};
t = cell2struct(out,{'places'},1);
or jast
t = t(~cellfun(@isempty,{t.places}));