So I have several structs that contains data that is used is a dozen or so scripts. The problem is that for each script I only need a handfull of variables and the rest I can ignore. I am using a massive amount of data (gigs of data) and MATLAB often gives me out of memory errors so I need to remove all unnecessary fields from the structs.
Currently I have a cell that contains all unneeded fields and then I call rmfield on the structs. But the fields in the structs often change and it is getting to be a pain to be constantly updating the list of unneeded fields. So is there a way to tell MATLAB to keep only those fields I want and remove everything else even if I don't know what everything else is?
Here is an example,
- Struct 1 has: A, B, C, D, E fields
- Struct 2 has: A, B, C, D, E, F fields
- Struct 3 has: A, B, C, D, E, F, G, H, I fields
Sometimes Struct 3 might only have A thru G.
I want to keep only A, B, and C fields and remove all other data from all the structs.