Performing Action to ALL 'struct' Variables
Ältere Kommentare anzeigen
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!
Akzeptierte Antwort
Weitere Antworten (1)
Fangjun Jiang
am 19 Mai 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 Kommentar
Philip
am 19 Mai 2011
Kategorien
Mehr zu Variables finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!