Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: two lslines on one plot
Replies: 1   Last Post: Jul 16, 2008 3:29 PM

 Messages: [ Previous | Next ]
 Daniel Walker Posts: 33 Registered: 7/27/07
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 x-axis data but
> different y-values. I'd like to use double y-axis
> (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
>
>

Date Subject Author
7/16/08 Young Ryu
7/16/08 Daniel Walker