
Re: two lslines on one plot
Posted:
Jul 16, 2008 3:29 PM


TRY THIS: x=1:50; y1 = 1.5*x + 5 + randn(size(x)); y2 = 1.1*x +100 + randn(size(x));
[AX, H1, H2]=plotyy(x, y1, x, y2);
set(H1,'Marker','.','linestyle','none'); set(H2,'Marker','o','linestyle','none');
axes(AX(1)); hold on; line( x, polyval(polyfit(x,y1,1),x)); axes(AX(2)); hold on; line( x, polyval(polyfit(x,y2,1),x));
"Young Ryu" <ryuyr77@gmail.com> wrote in message <g5leur$504 $1@fred.mathworks.com>... > Hi > > I have two data: both data have same xaxis data but > different yvalues. I'd like to use double yaxis > (plotyy), AND draw lslines for each data. > > [AX, H1, H2]=plotyy(x, y1, x, y2); > > Here, can you help how to draw each lsline (least squared > fit line) for each data(i.e. x vs y1 PLUS x vs y2) one the > plotyy figure? > > Thanks > >

