0

我正在尝试创建一个滑动窗口(带有一个滑块)来查看多个子图,每个子图都是一个很长的时间序列。

S=['set(gca,''xlim'',get(gcbo,''value'')+[0 ' num2str(chunkDuration) '])'];
h=uicontrol('style','slider','units','normalized','position',Newpos,...
    'callback',S,'min',0,'max',xmax-chunkDuration);

如前所述,这只会使底部的情节移动。我明白那是因为我设置了gca. 但是,更改gcfgca将无济于事,因为这会尝试设置xlimof 图形而不是其子级。

当我尝试

 kids = get(gcf,'Children')
 S=['set(kids,''xlim'',get(gcbo,''value'')+[0 ' num2str(chunkDuration) '])'];

我得到错误:

 ??? Undefined function or variable 'kids'.
 ??? Error while evaluating uicontrol Callback

那么,为什么上述方法不起作用?

即使在方法发生重大变化之后,问题仍然存在。

4

1 回答 1

1

Somewhere in your code you try to use a variable named subplot_handles. The error arises because this variable is undefined at the time you try to use it.

Update:

Is there a reason why you are saving your set commands as Strings? I suspect that its completely un-needed.

When you create your subplots try storing the handles to the axes created by the subplot objects.

ax(1) = subplot(311);
ax(2) = subplot(312);
ax(3) = subplot(313);

Later on you can set the limits for all subplots using:

set(ax, 'XLim', get(gcbo,'value') + [0  num2str(chunkDuration)] );
于 2013-01-16T03:38:34.150 回答