问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/14359231/too-many-input-arguments-to-uicontrol-callback