# fnxtr

Extrapolate spline

## Description

returns a spline of order `pp`

= fnxtr(`f`

,`order`

)`order`

that extrapolates the spline
`f`

. `pp`

equals `f`

on its basic
interval, but `pp`

is a polynomial of the given order outside that
interval. `pp`

satisfies at least `order`

smoothness
conditions at the ends of the basic interval of `f`

, that is, at the new
breaks. It is most useful to use a positive value of `order`

that is
smaller than the order of `f`

.

## Examples

### Extrapolate Cubic Smoothing Spline

Create a cubic smoothing spline on the unit interval.

x = rand(1,21); spline = csaps(x,x.^3);

Create an extrapolating spline of order 2.

order = 2; extrSpline = fnxtr(spline,order);

Plot the original spline together with the extrapolating spline.

fnplt(spline,[-.5 1.4]) hold on fnplt(extrSpline,[-.5 1.4]) legend('Cubic smoothing spline','Extrapolating spline') hold off

### Extrapolate Bivariate B-Spline

Create and plot a bivariate B-spline.

spline = spmak({0:3,0:4},1); fnplt(spline)

Create an extrapolating spline. To extrapolate in the first variable only, specify a negative integer as the extrapolation order in the second variable.

order = [3,-1]; extrSpline = fnxtr(spline,order); fnplt(extrSpline)

## Input Arguments

`f`

— Spline to extrapolate

structure

Spline to extrapolate, specified as a structure. `f`

must be a
spline in B-form, BBform, or ppform.

**Data Types: **`struct`

`order`

— Order of extrapolating spline

integer | vector of integers

Order of extrapolating spline, specified as an integer or a vector of integers.

If `order`

is zero, then the extrapolating spline describes the
same spline as `fn2fm(f,'B-')`

, but is in ppform and has a larger basic
interval.

If `order`

is at least as large as the order of
`f`

, then the extrapolating spline is the same spline as
`gn2fm(f,'pp')`

, but uses two more pieces and has a larger basic
interval.

If `f`

is *m*-variate, then
`order`

can be a vector with *m* elements, where
`order(i)`

is the order used to extrapolate in the
`i`

-th variable. To exclude the `i`

-th variable from
being used in the extrapolation, specify `order(i)`

as a negative
integer.

**Example: **1

## Output Arguments

`pp`

— Spline in ppform

spline structure

Spline in ppform, returned as a structure with these fields.

`Form`

— Form of spline

`pp`

Form of the spline, returned as `pp`

. `pp`

indicates that
the spline is given in piecewise polynomial form.

`Breaks`

— Knot locations of spline

vector | cell array

Knot positions of the spline, returned as a vector or as a cell array of vectors for multivariate data. Vectors contain strictly increasing elements that represent the start and end of each of the intervals over which the polynomial pieces are defined.

`Coefs`

— Coefficients of polynomials

matrix | array

Coefficients of polynomials for each piece, returned as a matrix or as an array for multivariate data.

`Pieces`

— Number of polynomial pieces

scalar | vector

Number of polynomial pieces describing the spline, returned as a scalar or as a vector of numbers of pieces in each variable for multivariate data.

`Order`

— Order of polynomials

scalar | vector

Order of the polynomial function describing each polynomial piece of the spline, returned as a scalar or as a vector containing the order in each variable for multivariate data.

`Dim`

— Dimensionality

scalar

Dimensionality of the target function, returned as a scalar.

## Version History

**Introduced in R2006a**

## Open Example

You have a modified version of this example. Do you want to open this example with your edits?

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

# Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)