MATLAB: How to add more parameters to callback function.

MATLABmatlab function

I want to add the new parameter 'a' to myfunction(obj,event_obj,a). I dont understant why there are no parameters at calling while the function has arguments.
How to call the function with 'a' parameter also?
Here is the code that is working without my new parameter:
function button_exponential_fit_Callback(hObject, eventdata, handles)
...
set(dcm, 'updatefcn', @myfunction)
function output_txt = myfunction(obj,event_obj)
pos = get(event_obj,'Position');
output_txt = {['X: ',num2str(pos(1),4)], ['Y: ',num2str(pos(2),4)]};
%disp(a)

Best Answer

The first two inputs for callback functions are fixed. You can add additional inputs by doing the following.
function button_exponential_fit_Callback(hObject, eventdata, handles)
...
set(dcm, 'updatefcn', {@myfunction, a})
% ________________ In curly brackets, add additional inputs
function output_txt = myfunction(obj,event_obj,a)
% ___ starting with input #3
end