Easiest way to load structure array from a text file
2 次查看(过去 30 天)
显示 更早的评论
I currently have a structure array defined in the code as:
C.a = "something";
C.b = 1;
% useful comment
C.c = [ 1.3, 2.0, 3.1];
I would like to create a text file that would contain the values so that i can compile the code and change the struct without recompilation. What is the easiest way to do this? ( I read about readstruct but that requires creating an xml file which is an overkill)
2 个评论
回答(1 个)
Scott MacKenzie
2021-7-16
编辑:Scott MacKenzie
2021-7-16
To save the data in the structure C in a file...
save('savedata.mat', 'C');
To retrieve the data as a structure C later...
load('savedata.mat');
I'm assuming here that the key issue is storing the data in a file and retrieving the data later in the same format. Of course, a .mat file is not a text file.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Text Files 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!