What are matlab.apps.AppBase objects and how do I check them?

36 visualizaciones (últimos 30 días)
Antonio
Antonio el 11 de Nov. de 2024 a las 10:53
Editada: Sameer el 11 de Nov. de 2024 a las 11:08
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!

Respuestas (1)

Sameer
Sameer el 11 de Nov. de 2024 a las 11:07
Editada: Sameer el 11 de Nov. de 2024 a las 11:08
"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!

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by