Plotting Least Squares Regression

Ben Abbott bpabbott at mac.com
Fri Dec 7 19:59:25 CST 2007


On Dec 7, 2007, at 8:04 PM, Ciaran Mooney wrote:

> Evening,
>
> I've gotten a bit further with my problem. I have found a forum post
> [http://forum.mandriva.com/viewtopic.php? 
> t=17602&highlight=&sid=ad0cf06d91bca350253fe355201262ae]
> that seems to detail what I want to do.
>
> I have successfully plotted a graph, and a line of best fit, that to
> me looks alright.
>
> When I type "p" at the prompt to find out what "polyfit(x,y)" has
> given me I get two values, in the equation y=mx+c, are these values m
> and c??

Ciarán, the polyfit/polyval functions for Octave are intended to be  
consistent with the same in Matlab.

http://www.mathworks.com/access/helpdesk/help/techdoc/index.html?/ 
access/helpdesk/help/techdoc/ref/polyfit.html&http://www.google.com/ 
search?q=matlab%20polyfit&sourceid=mozilla2&ie=utf-8&oe=utf-8

Thus is "p" has a length of 2, p(1) = m and p(0) = c.

You can fit to polynomials of a larger order using p = polyfit 
(x,y,N) .... where N = the order of the polynomial.

Thus, the answer to your question is "yes". Provided you meant  
"polyfit(x,y,1)"

Ben


More information about the Help-octave mailing list