0

I am trying to write a scroll bar that changes the x-range of many subplots at the same time.

kids = get(gcf,'Children');
 h=uicontrol('style','slider',...
'units','normalized','position',Newpos,...
'callback',{@slide_axes,kids},'min',0,'max',xmax-chunkDuration);

Update_axes is defined in the same file:

function slide_axes(h)
 set(h,'xlim',get(gcbo,'value')+[0 20000]); 

end

However, I get the error:

??? Error using plot_scroll>slide_axes
Too many input arguments.

??? Error while evaluating uicontrol Callback

I read on the FEX that callback may pass two arguments to any callback function. However, when I changed the signature of slide_axes to slide_axes(h,evt) the error remains.

mac389
  • 3,004
  • 5
  • 38
  • 62

1 Answers1

2

The arguments you are passing (h and evt) are MATLAB defaults. If you want to pass additional arguments to your callback function you need to write them after h and evt. Like this:

function slide_axes(h, evt, k)
    % k is kids.
end
HebeleHododo
  • 3,620
  • 1
  • 29
  • 38