Creating a loop to modify several hundred structures in the workspace

1 view (last 30 days)
Hi there,
I have a workspace containing 800+ structures. The timestamps that were generated in a data recording are incorrect. "time" is one of the fields contained in the structure. I have gotten to the point where I can extract the data I need (frequency and total time - not the same for each structure) to recreate a new time matrix of the correct size, but I can't get it to overwrite the old structure. I named the new time matrix "timearray"
I can get it to work if I manually input NameOfStructure.('time') = timearray
Because I am looping through the workspace I need to have the structure name represented as a variable
What I have now is either
eval(name).('time') = timearray or x{count}.('time') = timearray
where "name" is the structure name generated from whos, "x" is the entire output of whos, and "count" is the loop number (based on the size of workspace)
How can I get it to recognize S.(field) when S is constantly changing? Sidenote: I need the data to stay in this multi-structure format so I can reimport to the program that the original data came from.
Thanks so much for the help!

Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!