Handling external variables when redefining the text displayed by the data cursor
3 次查看(过去 30 天)
显示 更早的评论
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
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!