Why can't I save this structure as a .mat file?
8 views (last 30 days)
Show older comments
I'm trying to save a structure with several fields in matlab. The following lines save the data to the desired folder:
filename_output = [outpath subf(k).name '_timeseries.mat'];
save(filename_output,'-struct','my_structure');
But when I try to load the structure with:
load(filename_output)
I get a bunch of separate variables, not in a structure. Am I overlooking something?
0 Comments
Accepted Answer
Matt J
on 18 Aug 2017
Edited: Matt J
on 18 Aug 2017
You did not save a structure. The '-struct' option splits the fields of my_structure into separate variables before saving. However, it is best practice anyway to call load() with an output argument,
myStruct = load(filename_output)
and when you do you obtain your variables again in structure form.
More Answers (0)
See Also
Categories
Find more on Structures 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!