How do I save and load an app session?

17 views (last 30 days)
Par
Par on 28 Feb 2020
Answered: Anmol Dhiman on 6 Mar 2020
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

Answers (1)

Anmol Dhiman
Anmol Dhiman on 6 Mar 2020

Categories

Find more on Develop Apps Using App Designer in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!