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

조회 수: 1 (최근 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

답변 (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 CenterFile Exchange에서 Text Files에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by