Environmental Engineering Reference
In-Depth Information
parameter is the line vector of instants at which the polynomial is evaluated. The
output is a corresponding vector with values of the polynomial. The plot command
yields a visual comparison of the original values and the fitted curve:
plot(tfit,cfit,'o',[0:.2:8],c,'-');
Note that the fitting procedure is based on a quantitative measure for the quality
of an approximation. Such different evaluations are based on the residual vector ,
showing the difference between given and modelled values for all measurements:
c = polyval(p,tfit);
resc = cfit-c
resc =
0.0187 -0.0163 -0.0168 0.0175 -0.0031
There is no unique measure for the quality of a fit. One can use for
example the mean absolute error 1
,
N P cðt fit Þc fit
the mean quadratic error
q
P cðt fit Þc fit
2
or the max-
1
N
, the maximal absolute error max cðt fit Þc fit
n
o . There are even other measures
2
cðt fit Þc fit
imal quadratic error max
possible.
It is most common to check the quadratic error. The mean quadratic error for the
given approximation is obtained by the command:
sqrt(sum (resc.*resc))/5
ans =
0.0070
One may also use the square root of the sum of the squares of the residuals
normc = sqrt(sum(resc.*resc))
normc =
0.0348
This is the so called norm of the residuals which can also be obtained by the
commands:
normc = norm(resc)
or
normc = norm(resc,2)
For more details concerning the norm command, which can be used for alter-
native quality measurements, see the MATLAB
help. For every polynomial other
than the best fit, the deviation between measured and calculated values, quantified
in the residual norm, will be higher. Lets make one check:
®
Search WWH ::




Custom Search