least squares linear fit to be forced to pass through a specified point
Show older comments
How can least squares linear fit be forced to pass through a specified point
Answers (1)
the cyclist
on 7 Aug 2011
Do you have the Statistics Toolbox? If so, you could use the nlinfit() function to do this. Here is a simple example that you might be able to tailor to your needs:
% Data
x = 1:8;
y = 3*x + 0.4*rand(1,8);
% Example of linear model through a fixed point
f = @(p,x) p(1)*x - 0.2;
% Fit
beta0 = [1];
[beta,r,j,covb,mse] = nlinfit(x,y,f,beta0)
Categories
Find more on Least Squares in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!