Environmental Engineering Reference
In-Depth Information
10.2 Polynomial Curve Fitting
In order to outline the basic concepts of inverse modeling, we first focus on the
simple situation, in which the dependent variable obeys an analytical formula with
respect to a variable time t . Imagine the dependent variable being the concentration
of a pollutant. The reader may think of t as time. For a first approach it is even
assumed that this formula is a polynomial. The coefficients of the polynomial,
which are connected to the parameters, are unknown and have to be determined by
the inverse modeling procedure.
The best fit is that polynomial (represented by a set of coefficients that are the
parameters), for which the deviation between given values and modelled values is
minimal. For such polynomial curve fitting MATLAB
has the polyfit command.
Use the following command to find the best fit for the data-set given above under
the assumption that the formula is quadratic:
®
p = polyfit (tfit,cfit,2)
p =
0.0181 -0.2326 0.8099
The last formal parameter in the brackets on the right side specifies the degree of
the polynomial, i.e. the exponent of the highest power term. It needs to be above one
and lower or equal to the number of given measurements. MATLAB
returns the
coefficients of the polynomial in an array, here p . The answer shown above
corresponds to the polynomial:
®
0181 t 2
cðtÞ¼
0
:
0
:
2326 t þ
0
:
8099
(10.1)
Polynomials are evaluated by the polyval command. Use the following com-
mand in order to compute the values of the polynomial, given by ( 10.1 ), and just
obtained by parameter fitting:
c = polyval(p,[0:.2:8])
c =
Columns 1 through 7
0.8099 0.7641 0.7198 0.6769 0.6354 0.5954 0.5568
Columns 8 through 14
0.5197 0.4840 0.4498 0.4170 0.3857 0.3557 0.3273
Columns 15 through 21
0.3003 0.2747 0.2506 0.2279 0.2067 0.1869 0.1685
Columns 22 through 28
0.1516 0.1362 0.1222 0.1096 0.0985 0.0888 0.0806
Columns 29 through 35
0.0738 0.0684 0.0645 0.0621 0.0611 0.0615 0.0634
Columns 36 through 41
0.0667 0.0715 0.0777 0.0853 0.0944 0.1050
The first formal parameter of polyval is a line vector and is interpreted as the
polynomial whose coefficients are the elements of the vector. The second formal
Search WWH ::




Custom Search