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

11 visualizzazioni (ultimi 30 giorni)
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?

Risposta accettata

MathWorks Support Team
MathWorks Support Team il 5 Mag 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. 

Più risposte (0)

Categorie

Scopri di più su Interactive Control and Callbacks in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Prodotti


Release

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by