70 views

Uploaded by Francisca Claudia Melo Melo

- chap4.pdf
- Interpolation Project
- Scattered in Terp Course Notes
- Dry Pix 2000
- Tesi a.dmytriv
- splines
- Scalar and Parametric Splines Curves and Surfaces_-_Horacio Florez
- EGM6341_Sol_HW_05
- Approximating Sinusoidal Functions With Polynomials (1)
- gisc9318d4zamanm
- INTERPOLATE.xlsx
- f22-2-165-174
- CubicSplines
- Nbm Civ Inp Ppt Lagrange
- Interpolation 12786416547886 Phpapp01
- Fees Management System
- Optimizing Technique-grenade Explosion Method
- CA So Red Brand Canners
- GRAPH_03e
- Online Supermarket Shopping System

You are on page 1of 5

text://0

interp1

1-D data interpolation (table lookup)

Syntax

yi yi yi yi yi pp = = = = = = interp1(x,Y,xi) interp1(Y,xi) interp1(x,Y,xi,method) interp1(x,Y,xi,method,'extrap') interp1(x,Y,xi,method,extrapval) interp1(x,Y,method,'pp')

Description

yi = interp1(x,Y,xi) interpolates to find yi, the values of the underlying function Y at the points in the vector or array xi. x must be a vector. Y can be a scalar, a vector, or an array of any dimension, subject to the following conditions: If Y is a vector, it must have the same length as x. A scalar value for Y is expanded to have the same length as x. xi can be a scalar, a vector, or a multidimensional array, and yi has the same size as xi. If Y is an array that is not a vector, the size of Y must have the form [n,d1,d2,...,dk], where n is the length of x. The interpolation is performed for each d1-by-d2-by-...-dk value in Y. The sizes of xi and yi are related as follows: If xi is a scalar or vector, size(yi) equals [length(xi), d1, d2, ..., dk]. If xi is an array of size [m1,m2,...,mj], yi has size [m1,m2,...,mj,d1,d2,...,dk]. yi = interp1(Y,xi) assumes that x = 1:N, where N is the length of Y for vector Y, or size(Y,1) for matrix Y. yi = interp1(x,Y,xi,method) interpolates using alternative methods:

Nearest neighbor interpolation Linear interpolation (default) Cubic spline interpolation Piecewise cubic Hermite interpolation (Same as 'pchip') Cubic interpolation used in MATLAB 5. This method does not extrapolate. Also, if x is not equally spaced, 'spline' is used/

For the 'nearest', 'linear', and 'v5cubic' methods, interp1(x,Y,xi,method) returns NaN for any element of xi that is outside the interval spanned by x. For all other methods, interp1 performs extrapolation for out of range values. yi = interp1(x,Y,xi,method,'extrap') uses the specified method to perform extrapolation for out of range values. yi = interp1(x,Y,xi,method,extrapval) returns the scalar extrapval for out of range values. NaN and 0 are often used for extrapval. pp = interp1(x,Y,method,'pp') uses the specified method to generate the piecewise polynomial form (ppform) of Y. You can use any of the methods in the preceding table, except for 'v5cubic'. pp can then be evaluated via ppval. ppval(pp,xi) is the same as interp1(x,Y,xi,method,'extrap'). The interp1 command interpolates between data points. It finds values at intermediate points, of a one-dimensional function and yi. that underlies the data. This function is shown below, along with the relationship between vectors x, Y, xi,

1 of 5

21/8/2012 17:01

text://0

Interpolation is the same operation as table lookup. Described in table lookup terms, the table is [x,Y] and interp1 looks up the elements of xi in x, and, based upon their locations, returns values yi interpolated within the elements of Y. Note interp1q is quicker than interp1 on non-uniformly spaced data because it does no input checking. For interp1q to work properly, x must be a monotonically increasing column vector and Y must be a column vector or matrix with length(X) rows. Type help interp1q at the command line for more information.

Examples

Example 1

Generate a coarse sine curve and interpolate over a finer abscissa. x = 0:10; y = sin(x); xi = 0:.25:10; yi = interp1(x,y,xi); plot(x,y,'o',xi,yi)

Example 2

The following multidimensional example creates 2-by-2 matrices of interpolated function values, one matrix for each of the 2 3 4 three functions x , x , and x . x = [1:10]'; y = [ x.^2, x.^3, x.^4 ]; xi = [1.5, 1.75; 7.5, 7.75]; yi = interp1(x,y,xi);

2 of 5

21/8/2012 17:01

text://0

Example 3

Here are two vectors representing the census years from 1900 to 1990 and the corresponding United States population in millions of people. t = 1900:10:1990; p = [75.995 91.972 105.711 123.203 131.669... 150.697 179.323 203.212 226.505 249.633]; The expression interp1(t,p,1975) interpolates within the census data to estimate the population in 1975. The result is ans = 214.8585 Now interpolate within the data at every year from 1900 to 2000, and plot the result. x = 1900:1:2000; y = interp1(t,p,x,'spline'); plot(t,p,'o',x,y)

Sometimes it is more convenient to think of interpolation in table lookup terms, where the data are stored in a single table. If a portion of the census data is stored in a single 5-by-2 table, tab = 1950 1960 1970 1980 1990 150.697 179.323 203.212 226.505 249.633

then the population in 1975, obtained by table lookup within the matrix tab, is p = interp1(tab(:,1),tab(:,2),1975) p = 214.8585

Example 4

3 of 5

21/8/2012 17:01

text://0

The following example uses the 'cubic' method to generate the piecewise polynomial form (ppform) of Y, and then evaluates the result using ppval. x = 0:.2:pi; y = sin(x); pp = interp1(x,y,'cubic','pp'); xi = 0:.1:pi; yi = ppval(pp,xi); plot(x,y,'ko'), hold on, plot(xi,yi,'r:'), hold off

Algorithm

The interp1 command is a MATLAB M-file. The 'nearest' and 'linear' methods have straightforward implementations. For the 'spline' method, interp1 calls a function spline that uses the functions ppval, mkpp, and unmkpp. These routines form a small suite of functions for working with piecewise polynomials. spline uses them to perform the cubic spline interpolation. For access to more advanced features, see the spline reference page, the M-file help for these functions, and the Spline Toolbox . For the 'pchip' and 'cubic' methods, interp1 calls a function pchip that performs piecewise cubic interpolation within the vectors x and y. This method preserves monotonicity and the shape of the data. See the pchip reference page for more information.

For Real x and Complex Y. For interp1(x,Y,...) where x is real and Y is complex, you can use any interp1 method except for 'pchip'. The shape-preserving aspect of the 'pchip' algorithm involves the signs of the slopes between the data points. Because there is no notion of sign with complex data, it is impossible to talk about whether a function is increasing or decreasing. Consequently, the 'pchip' algorithm does not generalize to complex data. The 'spline' method is often a good choice because piecewise cubic splines are derived purely from smoothness conditions. The second derivative of the interpolant must be continuous across the interpolating points. This does not involve any notion of sign or shape and so generalizes to complex data. For Complex x. For interp1(x,Y,...) where x is complex and Y is either real or complex, use the two-dimensional interpolation routine interp2(REAL(x), IMAG(x),Y,...) instead.

See Also

interp1q, interpft, interp2, interp3, interpn, pchip, spline

4 of 5

21/8/2012 17:01

text://0

References

[1] de Boor, C., A Practical Guide to Splines, Springer-Verlag, 1978.

Was this topic helpful?

Yes

No

5 of 5

21/8/2012 17:01

- chap4.pdfUploaded byGetachew
- Interpolation ProjectUploaded byjanardhan
- Scattered in Terp Course NotesUploaded byMichael Parker
- Dry Pix 2000Uploaded byksbinhcamau
- Tesi a.dmytrivUploaded byPipino Il Breve
- splinesUploaded byMarco Milan
- Scalar and Parametric Splines Curves and Surfaces_-_Horacio FlorezUploaded byAndres Granados
- EGM6341_Sol_HW_05Uploaded byRaminShamshiri
- Approximating Sinusoidal Functions With Polynomials (1)Uploaded byMichael Lo
- gisc9318d4zamanmUploaded byapi-358717204
- INTERPOLATE.xlsxUploaded byŠhiññ Šóhäï
- f22-2-165-174Uploaded bySıddık Sarıcalar
- CubicSplinesUploaded byCarlos Alberto
- Nbm Civ Inp Ppt LagrangeUploaded byCarlos Abdiel Carrasquilla
- Interpolation 12786416547886 Phpapp01Uploaded byPedro Antunes
- Fees Management SystemUploaded byNiro Thakur
- Optimizing Technique-grenade Explosion MethodUploaded byuday wankar
- CA So Red Brand CannersUploaded byAngel Lizarraga Ramos
- GRAPH_03eUploaded byIrfan Gani
- Online Supermarket Shopping SystemUploaded bySatheswaran Rajasegaran
- AliFutureDirSurvey41904Uploaded byiro27
- Hllapi MacroUploaded by93321403
- NueUploaded byRicardo Gutierres Mendoza
- final doc.docxUploaded bysdfashvfjgh
- EXCEL FORMULA: CONTOH BORANG INPUTUploaded bydiamondcruise
- LessonsUploaded byjyothi1964
- Lecture 34 of iitUploaded byhimanshuvermac3053
- 16. Appendix D-code ListingUploaded byCrash Zerocool
- Riggin 4 Character AnmtnUploaded byPremod P Sankar
- Complex AnalysisUploaded byShuX13

- Bio GasUploaded byAlessandroamb
- SBF-50-anosUploaded bytharcisyo
- Potencial de Produção de Biogás Em Uma Estação de Tratamento de Esgoto de Cascavel Para Geração de Energia EletricaUploaded byAna Lua
- Mr 22 - Synara Layana Rocha BarbosaUploaded byFrancisca Claudia Melo Melo
- Sistema Nervoso CentralUploaded byFrancisca Claudia Melo Melo
- apostila eletricidadeUploaded byFrancisca Claudia Melo Melo
- Geração de energia elétrica a partir do biogás do tratamento de esgoto _ USP Rio+20Uploaded byFrancisca Claudia Melo Melo
- Jose AntonioUploaded byFrancisca Claudia Melo Melo
- Estudo Sobre o Potencial de Geração de Energia a Partir de Resíduos de Saneamento (Lixo, Esgoto), Visando Incrementar o Uso de Biogás Como Fonte Alternativa de Energia RenovávelUploaded byFrancisca Claudia Melo Melo
- v19n1a06.pdfUploaded byFrancisca Claudia Melo Melo
- BiogásUploaded byLuane Schiochet
- Apostila MatlabUploaded byCelsonico
- Perspectiva Nuclear Pós-FukushimaUploaded byFrancisca Claudia Melo Melo
- 250-988-1-PBUploaded bymarcosmorsch
- Geração de Energia No Campus a Partir Da Biodigestão AnaeróbicaUploaded byFrancisca Claudia Melo Melo
- eletro6Uploaded byFrancisca Claudia Melo Melo
- A Conversão Da Fonte Renovável Biogás Em EnergiaUploaded byFrancisca Claudia Melo Melo
- Aspectos Técnicos Relacionados à Geração de Energia Elétrica a Partir Do Lodo de EsgotoUploaded byFrancisca Claudia Melo Melo
- eletro11Uploaded byFrancisca Claudia Melo Melo
- eletro8Uploaded byFrancisca Claudia Melo Melo
- eletro4Uploaded byFrancisca Claudia Melo Melo
- eletro5Uploaded byFrancisca Claudia Melo Melo
- Energia Produzida a Partir de Estação de Tratamento de Esgoto _ Sanepar EducandoUploaded byFrancisca Claudia Melo Melo
- eletro7Uploaded byFrancisca Claudia Melo Melo
- 06-B&E-v2-n1-2005-p557-67.pdfUploaded bylucastlp
- eletro1Uploaded byFrancisca Claudia Melo Melo
- eletro9Uploaded byFrancisca Claudia Melo Melo
- eletro10Uploaded byFrancisca Claudia Melo Melo
- eletro2Uploaded byFrancisca Claudia Melo Melo
- eletro3Uploaded byFrancisca Claudia Melo Melo

- CalculationsUploaded byshortie2000
- math lesson plan copy johnUploaded byapi-314574119
- ACI CI Mejorando El Confinamiento Parte 1Uploaded byDario Quintanilla Huayta
- Slivniak2003 the Garden of Double MessagesUploaded byRP
- Form 2 - Short Story - One is One and All AloneUploaded byzara_adams
- Surgical Safety ChecklistUploaded byDewi Djasmi
- article_9002825Uploaded bycowley75
- romanticism realism neoclassicalismUploaded byapi-346377291
- ar1Uploaded byArnold Bacani
- Scribd is StupidUploaded byAlex Adre
- MM1_Procter and Gamble Case_VTNUploaded bybigg.boss.32658
- chap2Uploaded bynandhakumarme
- Light in All the Dark Places - Hitler's Nephew's Grandson a Jew in IsrealUploaded byShama
- vrt1-example.pdfUploaded byJapheth Areso
- Mens Salon Business PlanUploaded byKartik
- Right Now, India is the Richest CountryUploaded byMSK. SahaaDhevan
- Mmc Webinar for Release 2015-02-16Uploaded byqais652002
- Feeding TechniquesUploaded byAnkita Singh
- Sud Unit 1 Definitions CompleteUploaded bydenim2serv
- sonofusionUploaded byglucifer
- Chapter 1 Biochemistry and the Organization of CellsUploaded bykeziazah
- BW4HANAUploaded byAnonymous yjbAmQ
- How Women ArgueUploaded bysmellyworm7
- Astrology_ Cardinal Fixed and MutableUploaded byEhab Atari Abu-Zeid
- Jan 4 Pages - GowrieUploaded byTonya Harrison
- Koeksisters RecipeUploaded byliterarysparrow
- accelerometros entek IRDUploaded bykucho69
- 35378944 German ObstaclesUploaded bylauban
- Sunflower MechanismUploaded byMalidu Madawala
- Library Management - Servlets - PostgresUploaded bymuchimp