This action might not be possible to undo. Are you sure you want to continue?

Welcome to Scribd! Start your free trial and access books, documents and more.Find out more

**D. Hundley November 1, 2003
**

To work with piecewise deﬁned polynomials eﬃciently, Matlab uses a data structure to compactly hold all of the necessary ingredients. When you construct a cubic spline, this data structure is what will be returned, and this is the information it contains: • form For cubic splines, this will always be pp for piecewise polynomial. • breaks A vector with the domain data. Using n points will mean that this vector stores n values. • coefs An array that will be n−1×4 for cubic splines, storing the coeﬃcients of each of the n − 1 cubic polynomials (the coeﬃcients for the cubic term are in the ﬁrst column). • pieces The number of polynomials used (for cubic splines, this is always n − 1). • order This is always 4 for cubic splines. • dim The dimension of the output; for cubic splines, this is always 1. Here’s an example that will construct a spline (using the “Not-a-knot” condition): x = -4:4; y = [0 .15 1.12 2.36 2.36 1.46 .49 .06 0]; cs = spline(x,y); xx = linspace(-4,4,101); yy = ppval(cs,xx); plot(x,y,’o’,xx,yy,’-’); The ﬁrst three lines constructs the domain, the range, and puts the cubic spline into the data structure cs. If you type cs, Matlab will show you what is stored there. In the last three lines, we sample the domain at many more points, evaluate the cubic splines at these data points (note the use of the command ppval to do this), and ﬁnally it plots the original data together with the cubic splines. Additionally, one can deﬁne the derivatives at the endpoints (remember those two extra equations)- To do this is Matlab, use: 1

the SPI may not give a continuous second derivative. is continuous. Next. go to the second panel of the basic ﬁtting GUI (use the arrow at the bottom right). >> fit1 fit1 = type: ’spline’ coeff: [1x1 struct] >> fit1. . ﬁrst plot your data. To put the piecewise polynomial data structure into your workspace. Here’s an example: >> plot(x. however. Matlab will call pchip (for more information. i. • pchip has no overshoots and less oscillation if the data are not smooth. then in the Figure. the data structure corresponding to cs in our previous examples is stored as fit1.cs = spline(x. where a. one can use the GUI tools. The Basic Fitting GUI is now shown. [ a.coeff ans = form: ’pp’ breaks: [-4 -3 -2 -1 0 1 2 3 4] coefs: [8x4 double] pieces: 8 order: 4 dim: 1 “Spline Interpolant” (SI) or “Shape Preserving Interpolant” (SPI)? They are both piecewise cubic functions. and for SPI. the Basic Fitting menu will call on spline. Internally. Here are some diﬀerences (from Matlab’s website) between spline and pchip. click on: Tools → Basic Fitting. you can take a look at what this is. together with an illustrative example: • spline produces a smoother result. To do this.y. click on either spline interpolant or the related shape preserving interpolant. for SI. y.coeff. • pchip is less expensive to set up. • spline produces a more accurate result if the data consists of values of a smooth function. For example. b are the desired slopes. Back in the command window. b]). use Matlab’s help feature). and choose the Save to Workspace button.e. if I had Matlab save the structure as fit1. Alternatively.’o’) Basic Fitting GUI created variables in the current workspace.

t. y = [-1 -1 -1 0 1 1 1].’-.’) legend(’data’.01:3.’pchip’.’o’.s.t.t).y. . while the “shape preserving” interpolant does not. x = -3:3.y.t).4) Figure 1: Figure for the last example.p.• The two are equally expensive to evaluate. plot(x. s = spline(x. t = -3:.y. Note that the spline interpolant “overshoots” the data.’-’.’spline’. p = pchip(x.

- HPIESI Pres 04 Solar Collectors
- Bi Kakis 2012
- kuranidis
- ΑΠΟΤΙΜΗΣΗ ΥΦΙΣΤΑΜΕΝΟΥ ΚΤΙΡΙΟΥ
- APOTIMIS YFISTAMENOU
- APOTIMISI YFISTAMENOU KTIRIOU
- KANEPE
- ΚΑ.ΝΕ.ΠΕ. SAP2000
- ΚΑΝ_ΕΠΕ_2012_teliko_FEK_42_B_20_01_2012
- enisxisi
- Nist Ssi 2012
- Σχέδιο Νόμου Αυθαίρετα
- Dikaiwata Twn Politwn Kai Twn Epixeirhsewn Stis Sunallages Tous Me Tis Dhmosies Uphresies
- ΑΥΘΑΙΡΕΤΑ
- Adam Smith Condensed
- Ardeuseis.simiwseis
- Apoxeteyseis Simeioseis 02
- APOXETEYSEIS ASKISEIS 1
- Apoxeteyseis Simeioseis 01
- ydreyseis_askhseis1234
- Law, Legislation and Liberty
- Wind Turbine 2
- Η ΠΟΡΕΙΑ ΠΡΟΣ ΤΟΝ ΦΙΛΕΛΕΥΘΕΡΙΣΜΟ

- tesss
- Java_Part_1
- am2
- 52115-mt----reliability engineering
- ps10
- EE Undergraduate Student Survey
- 02 Rounding Errors
- Lecture 12
- Pattern Recogecognition
- 13.What is an Infocube
- modeling
- Multiphase flow in a porous media
- Syllabus (402050B) Finite Element Analysis (Elective IV)
- Links
- Welcome to ASC !
- Untitled
- Untitled
- Find the Equation
- 13zaq Parallel
- Partitioning
- download_cs111_03 Structure of a C Program
- DC Digital Communication PART3
- 4th Grade Math Vocab
- Matlab Z Transform
- ch01oddslns
- VHDL
- HW2
- Questions 11
- Review Question on Chapter5 Filter Structure
- Hawo

Are you sure?

This action might not be possible to undo. Are you sure you want to continue?

We've moved you to where you read on your other device.

Get the full title to continue

Get the full title to continue listening from where you left off, or restart the preview.

scribd