Mathematics    

Interpolation and Multidimensional Arrays

Several interpolation functions operate specifically on multidimensional data.

Interpolation Functions for Multidimensional Data  
Function
Description
interp3
Three-dimensional data interpolation.
interpn
Multidimensional data interpolation.
ndgrid
Multidimensional data gridding (ndfun directory).

This section discusses:

Interpolation of Three-Dimensional Data

The function interp3 performs three-dimensional interpolation, finding interpolated values between points of a three-dimensional set of samples V. You must specify a set of known data points:

The most general form for interp3 is

XI, YI, and ZI are the points at which interp3 interpolates values of V. For out-of-range values, interp3 returns NaN.

There are three different interpolation methods for three-dimensional data:

All of these methods require that X, Y, and Z be monotonic, that is, either always increasing or always decreasing in a particular direction. In addition, you should prepare these matrices using the meshgrid function, or else be sure that the "pattern" of the points emulates the output of meshgrid.

Each method automatically maps the input to an equally spaced domain before interpolating. If x is already equally spaced, you can speed execution time by prepending an asterisk to the method string, for example, '*cubic'.

Interpolation of Higher Dimensional Data

The function interpn performs multidimensional interpolation, finding interpolated values between points of a multidimensional set of samples V. The most general form for interpn is

1, 2, 3, ... are matrices that specify the points for which values of V are given. V is a matrix that contains the values corresponding to these points. 1, 2, 3, ... are the points for which interpn returns interpolated values of V. For out-of-range values, interpn returns NaN.

Y1, Y2, Y3, ... must be either arrays of the same size, or vectors. If they are vectors of different sizes, interpn passes them to ndgrid and then uses the resulting arrays.

There are three different interpolation methods for multidimensional data:

All of these methods require that X1, X2,X3 be monotonic. In addition, you should prepare these matrices using the ndgrid function, or else be sure that the "pattern" of the points emulates the output of ndgrid.

Each method automatically maps the input to an equally spaced domain before interpolating. If X is already equally spaced, you can speed execution time by prepending an asterisk to the method string; for example, '*cubic'.

Multidimensional Data Gridding

The ndgrid function generates arrays of data for multidimensional function evaluation and interpolation. ndgrid transforms the domain specified by a series of input vectors into a series of output arrays. The ith dimension of these output arrays are copies of the elements of input vector xi.

The syntax for ndgrid is

For example, assume that you want to evaluate a function of three variables over a given range. Consider the function

for , , and . To evaluate and plot this function:


  Comparing Interpolation Methods Triangulation and Interpolation of Scattered Data