Professional Documents
Culture Documents
Curve fitting is the process of constructing a curve, or mathematical function, that has the best fit to a series of datapoints, possibly subject to constraints. Curve fitting can involve either interpolation, where an exact fit to the data is required, or smoothing, in which a "smooth" function is constructed that approximately fits the data. A related topic is regression analysis, which focuses more on questions of statistical inference such as how much uncertainty is present in a curve that is fit to data observed with random errors. Fitted curves can be used as an aid for data visualization, to infer values of a function where no data are available, and to summarize the relationships among two or more variables.
The five least square curve fit available are discussed below : Linear :
Matlab command :
Polynomial :
Exponential :
Matlab command :
Logarithmic :
Matlab command :
Power:
Matlab command :
Linear Regression in MATLAB Fitting a least-squares linear regression is easily accomplished in MATLAB using the backslash operator: '\'. In linear algebra, matrices may by multiplied like this: output = input * coefficient
where the p is polynomial coefficient and a structure S for use with polyval to obtain error estimates or predictions http://www.mathworks.com/help/matlab/ref/polyfit.html
POLYVAL Evaluates a polynomial at given points
y = polyval(p,x) [y,delta] = polyval(p,x,S) y = polyval(p,x,[],mu) [y,delta] = polyval(p,x,S,mu) where the optional output structure S generated by polyfit to generate error estimates delta. delta is an estimate of the standard deviation of the error in predicting a future observation at x by p(x).
Since the slope is about 0.01, the resistance is about 100 ohms. 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