>> mdl=fitlm(X,Y)mdl = Linear regression model: y ~ 1 + x1Estimated Coefficients: Estimate SE tStat pValue ________ _______ _______ __________ (Intercept) 16.325 1.8303 8.9194 1.054e-16 x1 -1.1809 0.14751 -8.0059 4.5928e-14Number of observations: 250, Error degrees of freedom: 248Root Mean Squared Error: 1.19R-squared: 0.205, Adjusted R-Squared 0.202F-statistic vs. constant model: 64.1, p-value = 4.59e-14>> plot(X,Y,'.')hold onplot(X,polyval(p,X),'r.')hold onf=16.3250-1.1809*Xplot(X,f,'.b')Attached figure:in blue: datain red: polyfit regressionin green: fitlm model
polyfit does not fit the data whereas fitlm does. Is there anything I can do to fix that? I would rather not use fitlm as I have to do thousand of regressions and it seems more complex and using more memory
Best Answer