0

I'm trying to create a sliding window (with a slider) to view multiple subplots each of which is a long time series.

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);

As written, this only causes the bottom plot to move. I understand that's because I set gca. However, changing gcf to gca won't help because that would try to set the xlim of figure instead of its children.

When I try

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

I get the error:

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

So, why doesn't the above work?

Even after a substantial change in approach, the problems remain.

Community
  • 1
  • 1
mac389
  • 3,004
  • 5
  • 38
  • 62
  • It is encouraged to ask a new question if you are having a different problem. If there is an answer that solved your problem please accept it and ask a new question consisting of your "big edit". – HebeleHododo Jan 16 '13 at 13:00
  • There was no answer that solved my problem. I read more and tried a different approach. I'll move the 'big edit' to a new question. – mac389 Jan 16 '13 at 13:03
  • Just as a reminder; if you solved your problem on your own you can post an answer and accept it. That way, future users will benefit from your approach. – HebeleHododo Jan 16 '13 at 13:09
  • I wish I solved it. :-) I do, I will. (I have done that in the past.) – mac389 Jan 16 '13 at 13:09

1 Answers1

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)] );
slayton
  • 20,123
  • 10
  • 60
  • 89