deleting entries across all fields of a structure
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuesta aceptada
Matt Fig
el 9 de Oct. de 2012
Editada: Matt Fig
el 9 de Oct. de 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.
Más respuestas (0)
Ver también
Categorías
Más información sobre Structures en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!