I am making a self function to change te text displayed by the cursor in my GUI figure. This is what I have done by the time:
dcm=datacursormode(hAxes.figure);
datacursormode on
set(dcm,'update',@myfunction)
function output_txt = runnumber(obj,event_obj)
% Display the position of the data cursor
% obj Currently not used (empty)
% event_obj Handle to event object
% output_txt Data cursor text string (string or cell array of strings).
pos = get(event_obj,'Position');
%getCursorInfo(dcm)
%inputDrDataCell
% Get the handle to the data cursor.
menu = findall(get(gcf,'Children'),'Type','uicontextmenu');
menuCallback = get(menu,'Callback');
dataCursor = menuCallback{2};
% Get the coordinates if a datatip exists.
info = getCursorInfo(dataCursor);
if ~isempty(info)
number = info.DataIndex
end
output_txt = {['X: ',num2str(pos(1),4)],...
['Y: ',num2str(pos(2),4)],...
['Run number:',num2str(number)]};
% If there is a Z-coordinate in the position, display it as well
%if length(pos) > 2
% output_txt{end+1} = ['Z: ',num2str(pos(3),4)];
%end
end
However, I would like to pass more input arguments to @myfunction in order to display the name of the axis, the raw data file etc. Any help?