For callback functions, for example, a listener function of an event, the syntax is
function my_callback(obj,src,evnt)...end
However, even if the arguments 'src' and 'evnt' are not used in the body of 'my_callback' function, the unused arguments are still required to appear in the parentheses. I can replace them with '~':
function my_callback(obj,~,~)...end
But the unused arguments always need 2 positions when declaring the function. If I write 'my_callback' without the two '~':
function my_callback(obj,~,~)...end
Matlab will throw an error stating 'too many arguments'. What is the reason? Thank you!
Best Answer