MATLAB: Using hold on with plotyy

plotyy hold on

I couldn't find an answer out there, so i'll ask:
I want to plot into one axis many curves (by using a loop), using hold on. How do I use 'hold on' separately for each axis of plotyy?
Then, after this loop, I want to plot a set of points into the second y axis. The set of points does not exist until the loop is done. how do I use plotyy without initially plotting into both axes? can i plot into the second axes afterwards like this?
thanks in advance

Best Answer

plotyy() creates two axes on top of each other. The syntax
>> [ax h1 h2] = plotyy(x1,y1,x2,y2);
will put the handles to both axes in the variable "ax". Then you can use the syntax
>> hold(ax(1),...)
or
>> hold(ax(2),...)
to apply the hold to ones set of axes or the other.