I'm working on a continuously updating slider...
hsl = uicontrol(...); % Slider initializing stuff
vars=struct('hsl', hsl, 'x', x, 'y', y); % A bunch of stuff that my callback needs
set(hsl,'Callback',{@hsl_callback,vars});
addlistener(hsl,'ContinuousValueChange',@hsl_callback);
Here's the problem. If I leave it like that, I get the error "not enough input arguments" for the callback.
If I change the line to this:
addlistener(hsl,'ContinuousValueChange',@(vars)hsl_callback);
then I get the error "too many input arguments."
Is this not possible, or am I getting the syntax wrong?
If it helps, my callback function has this structure:
function hsl_callback(~,~,vars)
k = get(vars.hsl,'Value');
% plot x, y scaled by k
end
addlistener(hsl,'ContinuousValueChange',@() hsl_callback(vars));?addlistener(hsl,'ContinuousValueChange',@{hsl_callback,vars});, which doesn't work either.