MATLAB: How to fix one point with no error while curve fitting

curve fittingfittingMATLABplotStatistics and Machine Learning Toolbox

I have a data to fit linear plot. But I want to fit the first point with no error. I mean, the fitted curve should fix on the first point and then fit to the rest of the point in 'least square fit' method. How can I do that?

Best Answer

[Edited] removed least squares comment
You could give more importance to the first observation using weights, I do this using the fitlm function in the statistics toolbox:
x = 1:10; y = randn(10,1);
lm1 = fitlm(x,y);
lm2 = fitlm(x,y,'weights',[100, ones(1,length(y)-1)]);
scatter(x,y), hold on
plot(x, lm1.Fitted,'r')
plot(x, lm2.Fitted,'b')