mase201sp09_Feb24_PRINTABLE

# mase201sp09_Feb24_PRINTABLE - Curve fitting and...

This preview shows pages 1–3. Sign up to view the full content.

Curve fitting and interpolation • Curve Fitting Topics (Tues 2/17): – Fitting data to a linear equation – Assessing “goodness-of-fit” – Using a\b and MATLAB data fitting tools – Fitting data to an exponential equation (sec 8.2.2) – Fitting data to polynomial equations using 2/24/2009 1 MATLAB functions polyfit, polyval (sec 8.2.1) • Interpolation topics (today): – Linear and polynomial interpolation – Piecewise interpolation – MATLAB function interp1 – Interpolating functions of two variables with interp2 MASE201 Spring 2009 What’s the difference ? • Curve-fitting and interpolation both use pairs of data – The purpose of curve-fitting is usually to identify parameters in a theoretical relationship – The purpose of interpolation is to estimate a value of between known values of data 2/24/2009 2 • Examples of interpolation: – Approximation of curves where underlying function is not known (1-D) – smoothing image or surface data (2-D) MASE201 Spring 2009 Interpolating Functions • The simplest interpolating function is known as “Linear Lagrange” or “linear interpolation” for short 0 2 1 2 0 1 1 1 0 1 olve ) ( a x a y a x a y a x a x f y + = + = + = = 2/24/2009 3 2 1 2 1 1 1 2 2 1 2 2 1 1 2 1 2 1 2 1 2 1 2 1 1 2 2 1 1 2 0 : Rearrange ; : Solve y x x x x y x x x x y x x y x y x x x x y y y x x y y a x x y x y x a + = + = = = MASE201 Spring 2009 Figure 5-12 reproduced from Gilat and Subramaniam, “Numerical Methods for Engineers and Scientists.”, Wiley, 2008. Linear Lagrange Interpolation • Check values x y 1 1 2 2 ) ( ) ( y x x x x ( ) 2 1 2 1 ) ( y x x x x 2 1 2 1 1 1 2 2 y x x x x y x x x x y + = 2/24/2009 4 x 1 y 1 0 y 1 x 2 0 y 2 y 2 0.5 y 1 0.5 y 2 2 ) ( 2 1 x x + 2 ) ( 2 1 y y + MASE201 Spring 2009

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
Quadratic Lagrange Interpolation • Use three points for interpolation 2/24/2009 5 MASE201 Spring 2009 Figure 5-13 reproduced from Gilat and Subramaniam, “Numerical Methods for Engineers and Scientists.”, Wiley, 2008. Interpolate with higher order polynomials • Lagrange interpolation can be extended to polynomials of order n : ( ) = = = = = n i j j j i j n i i n i i i x x x x y x L y x f 1 1 1 ) ( ) ( ) ( 2/24/2009 6 MASE201 Spring 2009 Lagrange Interpolation: MATLAB You can easily implement Lagrange interpolation with polyfit and polyval built-in MATLAB functions xvec=[1:5]; yvec=[33 32 31 16 1]; xi = 1:0.05:5; 2/24/2009 7 %fit a 4th order polynomial for 5 data points fit4=polyfit(xvec,yvec,length(xvec)-1) yi =polyval(fit4,xi) MASE201 Spring 2009 Piecewise Interpolation • Similar to curve fitting, if there is a large
This is the end of the preview. Sign up to access the rest of the document.

## mase201sp09_Feb24_PRINTABLE - Curve fitting and...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online