Note: This page has been translated by MathWorks. Click here to see

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Interpolate 2-D or 3-D scattered data

Use `scatteredInterpolant`

to perform interpolation on a 2-D
or 3-D data set of scattered data.
`scatteredInterpolant`

returns the interpolant
`F`

for the given data set. You can evaluate `F`

at a
set of query points, such as `(xq,yq)`

in 2-D, to produce interpolated
values `vq = F(xq,yq)`

.

Use `griddedInterpolant`

to perform interpolation
with gridded data.

`F = scatteredInterpolant`

`F = scatteredInterpolant(x,y,v)`

`F = scatteredInterpolant(x,y,z,v)`

`F = scatteredInterpolant(P,v)`

`F = scatteredInterpolant(___,Method)`

`F = scatteredInterpolant(___,Method,ExtrapolationMethod)`

creates an
empty scattered data interpolant object.`F`

= scatteredInterpolant

specifies an interpolation method: `F`

= scatteredInterpolant(___,`Method`

)`'nearest'`

,
`'linear'`

, or `'natural'`

. Specify
`Method`

as the last input argument in any of the first
three syntaxes.

specifies both the interpolation and extrapolation methods. Pass
`F`

= scatteredInterpolant(___,`Method`

,`ExtrapolationMethod`

)`Method`

and `ExtrapolationMethod`

together as the last two input arguments in any of the first three
syntaxes.

`Method`

can be:`'nearest'`

,`'linear'`

, or`'natural'`

.`ExtrapolationMethod`

can be:`'nearest'`

,`'linear'`

, or`'none'`

.

Use `scatteredInterpolant`

to create the interpolant,
`F`

. Then you can evaluate `F`

at specific points
using any of the following syntaxes:

`Vq = F(Pq)`

Vq = F(Xq,Yq)

Vq = F(Xq,Yq,Zq)

Vq = F({xq,yq})

Vq = F({xq,yq,zq})

`Vq = F(Pq)`

specifies the query points in the matrix`Pq`

. Each row in`Pq`

contains the coordinates of a query point.`Vq = F(Xq,Yq)`

and`Vq = F(Xq,Yq,Zq)`

specify the query points as two or three matrices of equal size.`Vq = F({xq,yq})`

and`Vq = F({xq,yq,zq})`

specify the query points as grid vectors. Use this syntax to conserve memory when you want to query a large grid of points.

It is quicker to evaluate a

`scatteredInterpolant`

object`F`

at many different sets of query points than it is to compute the interpolations separately using the functions`griddata`

or`griddatan`

. For example:% Fast to create interpolant F and evaluate multiple times F = scatteredInterpolant(X,Y,V) v1 = F(Xq1,Yq1) v2 = F(Xq2,Yq2) % Slower to compute interpolations separately using griddata v1 = griddata(X,Y,V,Xq1,Yq1) v2 = griddata(X,Y,V,Xq2,Yq2)

To change the interpolation sample values or interpolation method, it is more efficient to update the properties of the interpolant object

`F`

than it is to create a new`scatteredInterpolant`

object. When you update`Values`

or`Method`

, the underlying Delaunay triangulation of the input data does not change, so you can compute new results quickly.

`scatteredInterpolant`

uses a Delaunay triangulation of the scattered
sample points to perform interpolation [1].

[1] Amidror, Isaac. “Scattered data interpolation methods
for electronic imaging systems: a survey.” *Journal of Electronic
Imaging*. Vol. 11, No. 2, April 2002, pp. 157–176.

`griddata`

| `griddatan`

| `griddedInterpolant`

| `meshgrid`

| `ndgrid`