x1 = [0:.1:40];
y1 = 4.*cos(x1)./(x1+2);
x2 = [1:.2:20];
y2 = x2.^2./x2.^3;
figure('position',[1 1 6*72 8*72])
ax1=axes;
ax2=axes;
set(ax2,'YAxisLocation','right');
hl1 = line(x1,y1,'Color','r','Parent',ax1);
this also does it:
figure;
hl1 = line(x1,y1,'Color','r');
ax2 = axes('Position',get(gca,'Position'),'YAxisLocation','right');
which strikes me as EXTREMELY similar to the example. it seems to be dependent upon position and that position can't be any old vector but actually grabbed from gca or ax1, etc? still confused. i need to be able to draw the axes independently of using line()
if i redo the call to line(ax1) it plots correctly. maybe it's a refresh thing? do i have to refresh ax1, somehow? i set() stuff on axes pretty rampantly in my code, i can't be re-calling the plotting stuff everytime...
ideas? i'm in 7.9.1.671 (R2009b) Service Pack 1
thanks