©1999 BG Mobasseri 15/24/99 INTERPOLATION AND CURVE FITTING Etter: pp. 164-184 June 16, ‘99.

Slides:



Advertisements
Similar presentations
Splines and Piecewise Interpolation
Advertisements

AP Statistics Section 3.2 C Coefficient of Determination
259 Lecture 17 Working with Data in MATLAB. Overview  In this lecture, we’ll look at some commands that are useful for working with data!  fzero  sum,
COMPUTER GRAPHICS CS 482 – FALL 2014 OCTOBER 8, 2014 SPLINES CUBIC CURVES HERMITE CURVES BÉZIER CURVES B-SPLINES BICUBIC SURFACES SUBDIVISION SURFACES.
Chapter 15 Above: GPS time series from southern California after removing several curve fits to the data.
EGR 105 Foundations of Engineering I
CS 445/645 Fall 2001 Hermite and Bézier Splines. Specifying Curves Control Points –A set of points that influence the curve’s shape Knots –Control points.
1 Curve-Fitting Spline Interpolation. 2 Curve Fitting Regression Linear Regression Polynomial Regression Multiple Linear Regression Non-linear Regression.
CITS2401 Computer Analysis & Visualisation
Path planning, 2012/2013 winter1 Robot Path Planning CONTENTS 1. Introduction 2. Interpolation.
ES 240: Scientific and Engineering Computation. InterpolationPolynomial  Definition –a function f(x) that can be written as a finite series of power functions.
Lecture 11 Chap. 15. Outline Interpolation – Linear Interpolation – Cubic Spline Interpolation – Extrapolation 15.2 Curve.
MATLAB EXAMPLES Interpolation and Integration 58:111 Numerical Calculations Department of Mechanical and Industrial Engineering.
Curve Fitting and Interpolation: Lecture (IV)
Lecture 9 Interpolation and Splines. Lingo Interpolation – filling in gaps in data Find a function f(x) that 1) goes through all your data points 2) does.
Today’s quiz on 8.2 A Graphing Worksheet 1 will be given at the end of class. You will have 12 minutes to complete this quiz, which will consist of one.
CpE- 310B Engineering Computation and Simulation Dr. Manal Al-Bzoor
 1999 BG Mobasseri1 8/29/2015 MATLAB GRAPHICS - PART II ADVANCED PLOTTING June 4, ‘99.
CMPS1371 Introduction to Computing for Engineers NUMERICAL METHODS.
Introduction to MATLAB for Engineers, Third Edition Chapter 6 Model Building and Regression PowerPoint to accompany Copyright © The McGraw-Hill Companies,
Scientific Computing Linear and Quadratic Splines.
Curve Fitting and Interpolation: Lecture (I)
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Curve Fitting.
Regression analysis Control of built engineering objects, comparing to the plan Surveying observations – position of points Linear regression Regression.
Curves.
Recap Summary of Chapter 6 Interpolation Linear Interpolation.
MECN 3500 Inter - Bayamon Lecture 9 Numerical Methods for Engineering MECN 3500 Professor: Dr. Omar E. Meza Castillo
Curve Fitting and Regression EEE 244. Descriptive Statistics in MATLAB MATLAB has several built-in commands to compute and display descriptive statistics.
Today’s class Spline Interpolation Quadratic Spline Cubic Spline Fourier Approximation Numerical Methods Lecture 21 Prof. Jinbo Bi CSE, UConn 1.
Polynomial Interpolation You will frequently have occasions to estimate intermediate values between precise data points. The function you use to interpolate.
Advanced Topics- Polynomials
Department of Mechanical Engineering, LSU Session IV MATLAB Tutorials Session IV Mathematical Applications using MATLAB Rajeev Madazhy
Curves. First of all… You may ask yourselves “What did those papers have to do with computer graphics?” –Valid question Answer: I thought they were cool,
Lecture 10 2D plotting & curve fitting Subplots Other 2-D Plots Other 2-D Plots Curve fitting © 2007 Daniel Valentine. All rights reserved. Published by.
41 - 4/24/2000AME 150L1 Solving Engineering Problems, Integrating Equations.
Interpolation.
6.094 Introduction to programming in MATLAB Danilo Šćepanović IAP 2008 Lecture 3 : Solving Equations and Curve Fitting.
Correlation – Recap Correlation provides an estimate of how well change in ‘ x ’ causes change in ‘ y ’. The relationship has a magnitude (the r value)
Essential Question: How do we decide for the degree of the polynomial with a variable? How do we determine the end behavior of a polynomial function?
Recap Cubic Spline Interpolation Multidimensional Interpolation Curve Fitting Linear Regression Polynomial Regression The Polyval Function The Interactive.
Polynomials, Curve Fitting and Interpolation. In this chapter will study Polynomials – functions of a special form that arise often in science and engineering.
1 Data Analysis Linear Regression Data Analysis Linear Regression Ernesto A. Diaz Department of Mathematics Redwood High School.
Spline Interpolation A Primer on the Basics by Don Allen.
Splines I – Curves and Properties based on: Michael Gleicher Curves, chapter 15 in Fundamentals of Computer Graphics, 3 rd ed. (Shirley & Marschner) Slides.
MODEL FITTING jiangyushan. Introduction The goal of model fitting is to choose values for the parameters in a function to best describe a set of data.
Curve Fitting Pertemuan 10 Matakuliah: S0262-Analisis Numerik Tahun: 2010.
Principles of Extrapolation
Recap Functions with No input OR No output Determining The Number of Input and Output Arguments Local Variables Global Variables Creating ToolBox of Functions.
1 Lecture 8 Post-Graduate Students Advanced Programming (Introduction to MATLAB) Code: ENG 505 Dr. Basheer M. Nasef Computers & Systems Dept.
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 4 Chapter 17 and 18 Interpolation.
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
Linear Algebra Curve Fitting. Last Class: Curve Fitting.
Fitting Equations to Data Chapter 7. Problems Classwork: 7.1, 7.8, 7.13, 7.22 Homework: 7.2, 7.9, 7.16, 7.23, 7.28.
Lecture 29: Modeling Data. Data Modeling Interpolate between data points, using either linear or cubic spline models Model a set of data points as a polynomial.
Introduction to Programming for Mechanical Engineers
Fitting Equations to Data
Data manipulation II: Least Squares Fitting
COMPUTER GRAPHICS CHAPTERS CS 482 – Fall 2017 SPLINES
EEE 244-7: Curve Fitting.
The Lease Squares Line Finite 1.3.
Curve-Fitting Spline Interpolation
Chapter 15 Curve Fitting : Splines
INTERPOLATION Prof. Samuel Okolie, Prof. Yinka Adekunle & Dr
Lecture 10 2D plotting & curve fitting
Chapter 12 Curve Fitting : Fitting a Straight Line Gab-Byung Chae
Least Squares Fitting A mathematical procedure for finding the best-fitting curve to a given set of points by minimizing the sum of the squares of the.
Splines and Piecewise Interpolation
Interpolation and curve fitting
9. Data Fitting Fitting Experimental Spectrum
Curve Fitting Filling in the gaps.
Presentation transcript:

©1999 BG Mobasseri 15/24/99 INTERPOLATION AND CURVE FITTING Etter: pp June 16, ‘99

©1999 BG Mobasseri 25/24/99 DEFINING INTERPOLATION Interpolation can be used in at least two ways –Subsampling (taking every other sample or more) a dense signal and later filling it in –Generating new data where none was previously available

©1999 BG Mobasseri 35/24/99 SUBSAMPLING Say you have a large sound file taking too long to transmit or too much space to store. One solution is to subsample it, send(store) the sparse data then fill in the gaps later

©1999 BG Mobasseri 45/24/99 EXAMPLE Keep the circles and discard the rest. Later, fill in the gaps

©1999 BG Mobasseri 55/24/99 VIDEO COMPRESSION Video captured at 30 frames/sec. contains a lot of redundancies Keep only a fraction of the frames and interpolate between them later This is implemented in the MPEG standard

©1999 BG Mobasseri 65/24/99 INTERPOLATION METHODS There are 3 major interpolation techniques –linear –cubic-spline( a 3rd degree polynomial) –polynomial fitting (polynomial of arbitrary order)

©1999 BG Mobasseri 75/24/99 LINEAR INTERPOLATION Simplest of its kind, works on the following principle error interpolation

©1999 BG Mobasseri 85/24/99 HOW DOES MATLAB DO IT? The main MATLAB’s routine for 1-D interpolation is interp1 with the following syntax –y i =interp1(x,y,x i,’method’) (x,y) are the original coarse data. x i ’s are the new finer positions to be interpolated, y i is the answer. See next

©1999 BG Mobasseri 95/24/99 Illustrating (x i,y i ) x x i y yiyi

©1999 BG Mobasseri 105/24/99 WORKING WITH interp1 Want to interpolate a sinc function with samples originally located at [-4:1:4]

©1999 BG Mobasseri 115/24/99 Linear interpolation:Try it! x=[-4:.1:4];%x-values y=[ ];%coarsely sampled data at x=-4,-3,... xfiner=[-4:0.5:4];%inerpolate at -4,-3.5,-3,... yfiner=interp1(x,y,xfiner,’linear’);%interpolate at new grid positions plot(x,y,xfiner,yfiner,'ro',xfiner,yfiner,'r-');

©1999 BG Mobasseri 125/24/99 LINEAR INTERPOLATION OF SINC Interpolated at 0.5 intervals

©1999 BG Mobasseri 135/24/99 DEFINING CUBIC-SPLINE When data is interpolated by cubic spline, it means we pass a 3rd order polynomial through each pair of points Since a polynomial is passed through a pair of points We can interpolate at arbitrary fine positions Between the two

©1999 BG Mobasseri 145/24/99 Example Let’s say we have passed y=x 2 between (1,1) and (2,2). We can read any intermediate y values by simply plugging in an x value

©1999 BG Mobasseri 155/24/99 CUBIC-SPLINE A more accurate interpolation can be achieved by passing 3rd degree polynomials through coarse data

©1999 BG Mobasseri 165/24/99 INTERPOLATING AN AM SIGNAL An amplitude modulated signal is

©1999 BG Mobasseri 175/24/99 Try it! Evaluate the AM signal with f m =2,f c =3 in the range 0<t<1 in increments of.01 Subsample it 20:1. Using the kept data points, perform linear and cubic-spline interpolation Compare your code with mine, next page

©1999 BG Mobasseri 185/24/99 My code

©1999 BG Mobasseri 195/24/99 Output graph original interpolated

©1999 BG Mobasseri 205/24/99 LINEAR VS. CUBIC spline gets closer to the actual curve CUBIC-SPLINE vs. LINEAR INTERPOLATION linear original spline

©1999 BG Mobasseri 215/24/99 FINER INTERPOLATION Smoother interpolation via spline FINER CUBIC-SPLINT INTERP.

©1999 BG Mobasseri 225/24/99 DIRECT READ-OFF interp1(x,y,2.5,’spline’) returns spline interpolated value of 6.1 at 2.5 x=0:5; y=[ ]; xi=0:.1:5; ylin=interp1(x,y,xi); ys=interp1(x,y,xi,'spline'); point=interp1(x,y,2.5,'spline')

©1999 BG Mobasseri 235/24/99 LEAST SQUARES CURVE FITTING Linear and cubic spline interpolations fit curves constrained to go through the data points A curve fitted using least squares may not pass through any data point but it will be “close” to all of them in the “least squares” sense

©1999 BG Mobasseri 245/24/99 LEAST SQUARES SENSE data Fit a line that on average is closets to all data points

©1999 BG Mobasseri 255/24/99 LEAST SQUARES OBJECTIVE Find a function,e.g. a polynomial of whatever order, that minimizes the mean square error MATLAB does this through polynomial regression

©1999 BG Mobasseri 265/24/99 DIFFERENCES WITH CUBIC SPLINE Both are polynomials but cubic splines are 3rd order polynomials. The big difference is that cubic spline fits separate 3rd degree polynomials per segment Least squares fits a single polynomial through all data points

©1999 BG Mobasseri 275/24/99 DEFINING A POLYNOMIAL Etter: pp An Nth degree polynomial is specified by N+1 coefficients If there are N+1 data points, an Nth degree polynomial will pass through all of them

©1999 BG Mobasseri 285/24/99 Example of polynomials It takes a first degree polynomial, a straight line, to connect two points It takes a 2nd degree polynomial to connect 3 points

©1999 BG Mobasseri 295/24/99 polyfit FUNCTION To fit an nth degree polynomial to (x,y) data use –p=polyfit(x,y,n) polyfit returns a vector p of n+1 coefficients in decreasing powers of x. So if then p=[a o,a 1,a 2,a 3,…,a N ]

©1999 BG Mobasseri 305/24/99 Evaluating and Plotting the Fitted Polynomial:polyval Once polynomial is specified through the vector p, it can be evaluated directly using –y=polyval(p,x) coarse x values vector of polynomial coefficients

©1999 BG Mobasseri 315/24/99 Example using polyfit Let x=[ ] and y= [ ] be the coarse data points. This is how to fit a 4th order polynomial p=polyfit(x,y,4);%p is the coeff. vector now let’s evaluate the polynomial at finer positions given by xfine=[0:0.1:5] yfine=polyval(p,xfine);%plot yfine to see

©1999 BG Mobasseri 325/24/99 RESULT data Fitted polynomial does not pass through any data point

©1999 BG Mobasseri 335/24/99 Comparing Interpolations In the following slides we start with the following data points –x=[ ]; –y=[ ]; We will then interpolate along x in increments of 0.1 using progressively larger order polynomials

©1999 BG Mobasseri 345/24/99 APPLYING polyfit Let’s fit a first degree y=mx+h to data. We’ll get m=0.54,h=

©1999 BG Mobasseri 355/24/99 3RD DEGREE POLYNOMIAL Coefficients are [ ]

©1999 BG Mobasseri 365/24/99 4th DEGREE POLYNOMIAL coeff= [ ]

©1999 BG Mobasseri 375/24/99 5th DEGREE POLYNOMIAL Expect the polynomial to pass through all the points (why?)

©1999 BG Mobasseri 385/24/99 Homework Take the data on page 33 and interpolate it in increments of 0.1 using –Linear interpolation –Cubic spline –Polynomial of 3rd degree –Superimpose your plots and show how they compare