assign loaded structs directly
2 次查看(过去 30 天)
显示 更早的评论
I wonder, if there is no nicer way for doing this:
mdlPara = load([datasetPath,datasetName]);
rename = fieldnames(mdlPara);
mdlPara = mdlPara.(rename{1});
I want to load different named structs in my script. For acessing the data in the script I want them to have the same name (mdlPara). But with just loading them the struct is named
mdlPara.OLDSTRUCTNAME.Data. ...
is there a nicer way to get the form
mdlPara.Data. ...
directly
0 个评论
回答(2 个)
Titus Edelhofer
2014-10-29
Hi,
not really. But what you can do is to save the data as individual variables originally. So when you save your structure OLDSTRUCTNAME, do
save('thefile.mat', '-struct', 'OLDSTRUCTNAME');
When you load them afterwards, you don't have the structure name in mdlPara.
Titus
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!