Transform a workspace variable into single .mat files
Show older comments
Dear all,
I cut out the first and last minute of my movement data. Additionally used only a specified time window of my data. I saved my data using:
trimmed_raw_data_together = {data.acc_pelvis_time_equal}.';
However, this new workspace variable is a 9x1 cell:

I would like to save each row as one single .mat file as shown above:

Figure 1 is processed data, figure 2 is raw data. Ideally I would like to name processed data similar to the raw data (e.g. pair#1_together_processed) as an iteration.
Kind regards and thank you very much for your support an suggestions.
Jonas
4 Comments
Matt J
on 26 Jan 2023
Why would you want to do that? Isn't it neater and more compact to have all variables in one file?
Jonas Bender
on 26 Jan 2023
prasanth s
on 27 Jan 2023
to Store the specified fields of the specified scalar structure as individual variables in the file. For example, save('filename.mat','-struct','S','a','b') saves the fields S.a and S.b.
Stephen23
on 8 Feb 2023
"Ideally I would like to name processed data similar to the raw data (e.g. pair#1_together_processed) as an iteration."
Ideally you would have exactly the same variable names in every MAT file, then your data importing and exporting will be simpler and much more robust than having changing variable names. By all means number the filenames sequentially, but if you want to reduce wasted time (writing code, debugging code, running code), keep the variable names constant.
Accepted Answer
More Answers (0)
Categories
Find more on Workspace Variables and MAT Files in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!