In
addition, griddata will not accept any input
vectors of mixed orientation in a future release. To specify a grid
of query points, construct a full grid with ndgrid or meshgrid before
calling griddata.

vq = griddata(x,y,v,xq,yq) fits
a surface of the form v = f(x,y) to the scattered data in the vectors (x,y,v). The griddata function interpolates
the surface at the query points specified by (xq,yq) and returns the interpolated values, vq.
The surface always passes through the data points defined by x and y.

vq = griddata(x,y,z,v,xq,yq,zq) fits
a hypersurface of the form v = f(x,y,z).

vq = griddata(___,method) uses
a specified interpolation method to compute vq using
any of the input arguments in the previous syntaxes.

Input Arguments

x

Vector specifying the x- coordinates of the
sample points.

y

Vector specifying the y- coordinates of the
sample points.

z

Vector specifying the z- coordinates of the
sample points.

v

Vector of sample values that correspond to the sample coordinates x, y (and z for
3-D interpolation).

xq

Vector or array that specifies x- coordinates
of the query points to be evaluated. xq must be
the same size as yq (and zq for
3-D interpolation).

Specify an array if you want to pass a grid of query
points. Use ndgrid or meshgrid to construct the array.

Specify a vector if you want to pass a collection
of scattered points.

yq

Vector or array that specifies y- coordinates
of the query points to be evaluated. yq must be
the same size as xq (and zq for
3-D interpolation).

Specify an array if you want to pass a grid of query
points. Use ndgrid or meshgrid to construct the array.

Specify a vector if you want to pass a collection
of scattered points.

zq

Vector or array that specifies z- coordinates
of the query points to be evaluated. zq must be
the same size as xq and yq.

Specify an array if you want to pass a grid of query
points. Use ndgrid or meshgrid to construct the array.

Specify a vector if you want to pass a collection
of scattered points.

method

Keyword that specifies the interpolation method. Use one of
the following:

method string

Description

Continuity

'nearest'

Triangulation-based nearest neighbor interpolation supporting
2-D and 3-D interpolation.

Discontinuous

'linear'

Triangulation-based linear interpolation (default) supporting
2-D and 3-D interpolation

C^{0}

'natural'

Triangulation-based natural neighbor interpolation supporting
2-D and 3-D interpolation. This method is an efficient tradeoff between
linear and cubic.

C^{1} except at sample points

'cubic'

Triangulation-based cubic interpolation supporting 2-D interpolation
only

C^{2}

'v4'

Biharmonic spline interpolation (MATLAB^{®} 4 griddata method)
supporting 2-D interpolation only. Unlike the other methods, this
interpolation is not based on a triangulation.

C^{2}

Output Arguments

vq

The interpolated values at the query points.

For 2-D interpolation, where xq and yq specify
an m-by-n grid of query points, vq is
an m-by-n array.

For 3-D interpolation, where xq, yq,
and zq specify an m-by-n-by-p grid
of query points, vq is an m-by-n-by-p array.

If xq, yq, (and zq for
3-D interpolation) are vectors that specify scattered points, vq is
a vector of the same length.