What are matlab.apps.AppBase objects and how do I check them?
36 次查看(过去 30 天)
显示 更早的评论
Hello all,
I have an app with a figure that I'm saving, and despite being able to save it succesfully using saveas, I get the next warning (twice)
Warning: Unable to save App Designer app object. Save not supported for matlab.apps.AppBase objects.
I don't really mind, but I'd rather understand the warning, someone cares to explain?
Thanks in advance!
0 个评论
回答(1 个)
Sameer
2024-11-11,11:07
编辑:Sameer
2024-11-11,11:08
Hi @Antonio
"matlab.apps.AppBase" is a class that serves as a base class for apps created using App Designer. When you create an app in App Designer, the app is essentially an object that inherits from "matlab.apps.AppBase". This class provides the necessary infrastructure for the interactive components and the overall app framework.
The warning you’re seeing, “Unable to save App Designer app object. Save not supported for matlab.apps.AppBase objects,” occurs because MATLAB does not support saving instances of App Designer apps directly. This is due to the complex nature of these objects, which include UI components and callbacks that cannot be serialized easily
To work around this, you can save the data and state of your app separately.
1. Extract the data you need from your app and save it to a ".mat" file.
2. When you reload your app, read the data from the ".mat" file and restore the state of your app.
Here’s a simple example:
% Save data
data = struct;
data.Property1 = app.Property1;
data.Property2 = app.Property2;
save('appData.mat', 'data');
% Load data
loadedData = load('appData.mat');
app.Property1 = loadedData.data.Property1;
app.Property2 = loadedData.data.Property2;
Hope this helps!
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!