How do I save and load an app session?

16 次查看(过去 30 天)
I have made an app in Appdesigner, and would like to save the session and load it at a later time. I tryed to save the app object, close the application, open the application and load the app object. That resultet in multiple app sessions. I have also saved the fields of the app object to a struct with a different name. That generated the following warnings:
-Warning: Unable to save App Designer app object. Save not supported for matlab.apps.AppBase objects.
-Warning: Unable to save App Designer app object. Save not supported for matlab.apps.AppBase objects.
The process was later reversed to obtain the saved fields to the app object (the code is shown below). That resultet in the following warnings:
-Warning: While loading an object of class 'My_app': Unable to load App Designer app object. Load not supported for matlab.apps.AppBase objects.
Is it really not possible to save/load app objects?
function SavemetadataMenuSelected(app, event)
[file,path] = uiputfile('*.mat', 'Store calibration:','init_raw.mat');
fields = fieldnames(app);
data = struct;
for i = 1:numel(fields)
data.(fields{i}) = app.(fields{i});
end
data = rmfield(data,'UIFigure');
try
save(fullfile(path,file),'data')
catch ME
warning('Warning during saving: %s %s', ME.identifier, ME.message)
end
end
% Menu selected function: LoadmetadataMenu
function LoadmetadataMenuSelected(app, event)
uiopen('init_raw.mat')
fields = fieldnames(data);
for i = 1:numel(fields)
app.(fields{i}) = data.(fields{i});
end
show_img(app);
plot_calibration(app);
end

回答(1 个)

Anmol Dhiman
Anmol Dhiman 2020-3-6

类别

Help CenterFile Exchange 中查找有关 Develop Apps Using App Designer 的更多信息

产品


版本

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by