Download Curve Fitting - Ecs.csus.edu

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts

Multidimensional empirical mode decomposition wikipedia , lookup

P versus NP problem wikipedia , lookup

Immunity-aware programming wikipedia , lookup

Transcript
EEE 244-7: Curve Fitting
Need for curve fitting
• Engineering projects involve collection of data, such
as line voltage, cellular signal power
• Curve fitting provides a smooth fit to the data by an
approximating function
• Data can be approximated by polynomial functions
and splines
Polynomial functions
• Approximating curve yc represented by an mth order
polynomial:
• Polynomial coefficients c1, c2 ……cm+1 values are
obtained from data points
• Linear or straight line fit: m = 1
Nonlinear fit : m > 1
3
Matlab functions for polynomial curve fitting
• The coefficient matrix C = [c1, c2 ……cm+1] can be
calculated by the Matlab polyfit command:
C = polyfit(x,y,m)
where [x y] is the data set
m is the order of the polynomial
• The command polyval (C,x0) gives the value of the
polynomial at the point x0
4
Example of polynomial curve fitting
5
Cubic splines
• Polynomial approximation can produce points that
are not allowed
• For example, if the data is for absolute voltage,
polynomial can have negative and positive values
• Splines are piecewise approximating cubic functions
that can overcome polynomial problems
6
Matlab command for cubic splines
• The Matlab command interp1 creates cubic spline
set
• Given the data set [x y], the command:
yi = interp1(x,y,xi, spline)
yields the value of the function at the point xi
• The function can be obtained by giving a range of
[xi yi[
7
Example of curve fitting
Given the following data set:
Write a Matlab program to fit a curve using:
• Polynomial function of order 3
• Cubic spline fit
In both cases, sketch the approximating function
8