MATLAB: How to do a linear fit with forced slope

constrained least-squares linear regressionforcing constraintleast-squares linear regressionlinear fittinglinear regressionMATLAB

I'm trying to make a best fit of data forcing the slope of a linear fitting…is it possible? How?

Best Answer

If your data are column vectors x and y and your model is
y=m*x+b
then the solution for b would simply be
b_fit = mean(y-m*x);
Related Question