Performing Action to ALL 'struct' Variables
Mostrar comentarios más antiguos
Is there a way to perform the same action on several variables of type 'struct'?
In my case, I have 30 separate 'struct' variables (with non-logical names), and each of them contains a single vector of 200 elements. I only want to deal with the second half of these elements so I need something like:
struct_name = struct_name.data(100:end)
But need to keep the name of the struct variable intact. Does anyone have any suggestions?
I hope this made sense!
Respuesta aceptada
Más respuestas (1)
Fangjun Jiang
el 19 de Mayo de 2011
Would this help?
a(200).b=1;
a(200).c=0;
NewStruct=a(100:end);
Or, Do you mean keep the struct variable name, not the field names:
a(1:99)=[];
Now I think you mean this:
a.Data=1:200;
a.Data(1:100)=[]
1 comentario
Philip
el 19 de Mayo de 2011
Categorías
Más información sobre Variables en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!