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

11 ビュー (過去 30 日間)
MathWorks Support Team
MathWorks Support Team 2017 年 5 月 5 日
回答済み: MathWorks Support Team 2017 年 5 月 5 日
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?

採用された回答

MathWorks Support Team
MathWorks Support Team 2017 年 5 月 5 日
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. 

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeInteractive Control and Callbacks についてさらに検索

タグ

タグが未入力です。

製品


リリース

R2015a

Community Treasure Hunt

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

Start Hunting!

Translated by