Why can't I save this structure as a .mat file?

8 次查看(过去 30 天)
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?

采纳的回答

Matt J
Matt J 2017-8-18
编辑:Matt J 2017-8-18
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.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by