フィルターのクリア

Handling external variables when redefining the text displayed by the data cursor

2 ビュー (過去 30 日間)
Isabelle Braems
Isabelle Braems 2018 年 1 月 24 日
回答済み: Jordy Jose 2018 年 1 月 31 日
Hello everyone,
I would like to customize a matlab example defined to modify the text defined by the data cursor. The purpose is to make the data cursor dispay information that differs from its position.
The original scritp mainly looks like: fig= figure; dcm_obj = datacursormode(fig); set(dcm_obj,'UpdateFcn',@myupdatefcn)
My point is that I want to add input to the function handled by @myupdatefcn but I do not know how to call this input within the set command. Maybe it is trivial and I do not have the right keywords to check. Does someone have an idea? Many thanks in advance

回答 (1 件)

Jordy Jose
Jordy Jose 2018 年 1 月 31 日
hi Isabelle,
You may pass additional arguments like this:
val = 10;
set(dcm_obj,'UpdateFcn', {@myupdatefcn, val});
For more details regarding callback definitions, please refer to the link below:
https://www.mathworks.com/help/matlab/creating_plots/callback-definition.html
The function definition for myupdatefcn will look something like this:
function out = myupdatefcn(src, evt, val)
%your code here: val will be equal to 10
end

カテゴリ

Help Center および File ExchangeWhos についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by