Can I save my callback function within a .fig file?

11 visualizaciones (últimos 30 días)
I have a .fig file with a custom callback function. When I save a .fig file and reopen the figure, this functionality is lost unless I have the callback function saved on the path. Is there a way to save the callback function in the figure, or have the figure automatically add the callback function to the path?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 5 de Mayo de 2017
It is not currently possible to save the code for the callback function inside of the ".fig" file or have the figure add the callback function to the path, however there is a possible workaround.
Instead of saving the figure directly as a ".fig" file, you can instead save a function or script which can generate this file. Note that this script can the original program which made the figure, or a new file to simply load the necessary data in order to recreate the figure. Once this script or function exists, you can then define the desired callback function as a local function within your file. This way, whenever you want to view the figure, you will also have access to the appropriate callback function.
Note: The ability to define local functions within a script was introduced in the R2016b release of MATLAB. 

Más respuestas (0)

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Productos


Versión

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by