How to save a callback function

4 ビュー (過去 30 日間)
Sylvain
Sylvain 2020 年 2 月 24 日
コメント済み: Adam 2020 年 2 月 24 日
I need to save a datacursormode callback function, as a local variable (at least the syntax) . The argument of this function is my object
I am updating an object and then passing the saved function and the updated object in my datacusrormode UpdateFcn.
How to do it ? I tried the func2str and str2func without success.
  1 件のコメント
Adam
Adam 2020 年 2 月 24 日
It would help if you showed some relevant part of code for your problem as I'm not really sure I understand what it is you are wanting to do. You can save a callback as a function handle simply by doing something like this:
f = @myCallbackFcn;
where myCallbackFcn is defined somewhere as:
function myCallbackFcn( ~, eventObj )
...
end
You can also use an anonymous function if you wish to pass in more arguments than the default mandatory ones for that callback.

サインインしてコメントする。

回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by