MATLAB: Regression

regression

How can we display the regression equation (obtained by camand "fit") in the plot?

Best Answer

Here is an example:
x = (1:20)';
y = 2 + 3*x + 7*rand(20,1);
model = fit(x,y,'poly1')
figure
plot(model,x,y)
The plot command here is an "overloaded" method for cfit objects (the output of the fit command). The documentation is here: http://www.mathworks.com/help/toolbox/curvefit/plot.html