Sei sulla pagina 1di 46

Advanced Mathematical Methods for Civil Engineering Applications

Numerical techniques for interpolation & curve fitting

Wonsiri Punurai, PhD Department of Civil Engineering Room 6391, EG Building 3 Faculty of Engineering, Mahidol University Class Web: www.egmu.net/~civil/wonsiri

Basic Problems in relation to CE work


25

0 75

50

Experimental Data

Dial Gauge

Curve Fitting
{ { {

Linear Regression Polynomial Regression Multiple Linear Regression

Linear Regression

Errors do exist between model and observation. Find the best line which minimizes the sum of error for all data

Least-square Fit of a Straight Line


{

Minimize sum of the square of the errors

Differentiate with respect to each coefficient:

How good is our fit?

Confidence Interval (CI)

Linear Regression with MATLAB


{

Matlab function regress addresses the multiple linear regression problem based on the least squares approach. Matlab function regress estimates the model parameters and performing the regression model automatically. The regress function requires that the matrix of independent variables include a column of ones so that the model contains a constant term.

Example use of function regress


{

Given the following independent observations for variable Q and t:


1 2 2 0 3 5.5 4 7.9 5 12 6 12.5 7 14 8 15 9 19 10 19.9

t Q

1 2

2 0

3 5.5

4 7.9

5 12

6 12.5

7 14

8 15

9 19

10 19.9

20 18 16 14 12 10 8 6 4 2 0 Q

5 t

10

Figure 1: Plot of variable Q vs. t

Now one wants to check if there exists a linear relationship between Q and t (e.g. one wants to predict Q when t is 11 and 12 >> Use the regress function to estimate the model parameter and perform regression analysis. >>The regress function requires that the matrix of independent variables include a column of ones so that the model contains a constant term.

Create x in matlab

Now lets apply the regress function to our data (note that Q and t have to be transposed according to the function requirements):

Vector of regression Q=b1+tb2+

95% CI for b1 95% CI for b2

Confidence intervals Default is 95% CI If contains zero, the constant shall be excluded.

Discussion

As a result, our model that can be used for prediction Q for given t look as follow

Q=2.0081t

25 Data Model 20

15 Q 10 5 0 1

5 t

10

Figure 2 Original data and estimated regression model

Qt

Qt-1

Qt

Qt-1

Curve Fitting
{ { {

Linear Regression Polynomial Regression Multiple Linear Regression

Polynomial Regression
Model equation

Sum sq. error

0=

Normal Equations

Polynomial Regression with MATLAB

Solving previous example using Matlab


Fit a 2nd order polynomial

Matlab Polyval function

Polyval Example

Error Bounds

Multiple Linear Regression

Multivariate Fit in Matlab

Example

Potrebbero piacerti anche