I have a set of points (x,y)
and I need to find the line of best-fit that passes through the origin using MATLAB.
The regression line is forced to pass through the origin (0, 0). Therefore, unless your regressors are standardized or mean-centered, it's not a good idea to set the intercept to 0 when fitting the model.
A line of best fit can only be drawn if there is strong positive or negative correlation. The line of best fit does not have to go through the origin.
If the line cuts directly through the origin, this means that at one point, one of these coordinates is equal to zero.
The best fit line, in general, passes through the centroid of the data (average the x's and average the y's). So find the centroid and plot the line from the origin through the centroid.
if you have the "Curve Fitting Toolbox" you can use
f = fit( x, y, 'a*x' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With