deleting entries across all fields of a structure
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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
0 Kommentare
Akzeptierte Antwort
Matt Fig
am 9 Okt. 2012
Bearbeitet: Matt Fig
am 9 Okt. 2012
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.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Structures finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!