uicontrol回调输入参数过多 [英] Too many input arguments to uicontrol callback

查看:388
本文介绍了uicontrol回调输入参数过多的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图编写一个滚动条,以同时更改许多子图的x范围.

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在同一文件中定义:

Update_axes is defined in the same file:

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

结束

但是,我得到了错误:

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

??? Error while evaluating uicontrol Callback

我在FEX上读到,回调可能会将两个参数传递给任何回调函数.但是,当我将slide_axes的签名更改为slide_axes(h,evt)时,错误仍然存​​在.

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.

推荐答案

您要传递的参数(hevt)是MATLAB的默认值.如果要将其他参数传递给回调函数,则需要在hevt之后编写它们.像这样:

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

这篇关于uicontrol回调输入参数过多的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆