MATLAB: Deleting entries across all fields of a structure

indexstructure

I have a datastructure docMetaS =
DOCUMENT_ID: [184899x1 int32]
DOCUMENT_PUBLISHER: [184899x1 int32]
LIST_PRICE: [184899x1 int32]
PRIMARY_CATEGORY: {184899x1 cell}
PAGES: [184899x1 int32]
index = [80:100]
I would the elements with indices from 80 to 100 for all the fields in the structure.
I know it is possible to do using docMetaS.DOCUMENT_ID(index) =[];
and so on for all the four elements.
Is there a elegant way to do this in one or two statements?
Thanks,
Sankar

Best Answer

An example:
% Create a structure with multiple fields.
S.a = rand(1,100);
S.b = rand(1,100);
S.c = rand(1,100);
S.d = cellfun(@(x) rand,cell(1,100),'Un',0);
S % Show the structure, then delete some of it:
S = structfun(@(x) x([1:79 90:100]),S,'Un',0);
S % Show the reduces structure.