Linear Regression With Matlab
Linear Regression With Matlab
http://www.swarthmore.edu/NatSci/echeeve1/Ref/Matlab/CurveFit/L...
1 de 5
http://www.swarthmore.edu/NatSci/echeeve1/Ref/Matlab/CurveFit/L...
2 de 5
http://www.swarthmore.edu/NatSci/echeeve1/Ref/Matlab/CurveFit/L...
3 de 5
http://www.swarthmore.edu/NatSci/echeeve1/Ref/Matlab/CurveFit/L...
Since the slope is about 0.01, the resistance is about 100 ohms. It is also possible to use Matlab do the curve-fit and then calculate the correlation coefficient. In the following code "p" contains coefficients of linear, or first order, fit (slope=m=p(1)=0.0100, intercept=b=p(2)=0.006).
>> p=polyfit(x,y,1) p = 0.0100 0.0006 >> R=corrcoef(x,y); >> R(1,2) ans = 0.9961
A correlation coefficient with a magnitude near 1 (as in this case) represents a good fit. As the fit gets worse, the correlation coefficient approaches zero.
email me with any comments on how to improve the information on this page (either presentation or content), or to let me know if you had any particular difficulties with this lab. You may use any portion of this document for your lab report, but be sure to reference it. Back
4 de 5
http://www.swarthmore.edu/NatSci/echeeve1/Ref/Matlab/CurveFit/L...
5 de 5