Skip to Main Content Skip to Search
Product Documentation

griddedInterpolant class -

Interpolant for gridded data

Description

The griddedInterpolant class constructs an interpolant F from a gridded data set. The interpolant F is an interpolating function that can be evaluated at query locations.

Construction

F = griddedInterpolant(x,v) takes vectors x and v of equal length and creates an interpolant F. The first input argument, x, is a vector of sample points. v is a vector of corresponding values such that v = f(x). The interpolant F interpolates a vector of query locations xq using vq = F(xq) to return the interpolated values vq.

F = griddedInterpolant(X1,X2,...,Xn,V) specifies a grid as n n-dimensional arrays Xi. The grid (X1, X2,...,Xn) is created from grid vectors xgi by [X1,X2,...,Xn] = ndgrid(xg1,xg2,...,xgn).

F = griddedInterpolant(V) creates an interpolant F through the n-dimensional array of values V using the default grid formed by grid vectors xgi = 1:size(V,i).

F = griddedInterpolant({xg1,xg2,...,xgn},V) specifies the grid in compact form in terms of grid vectors xgi, where length(xgi) is size(V,i).

F = griddedInterpolant(...,Method) specifies the interpolation method. The values for 'Method' are nearest, linear (default), spline, pchip, or cubic.

The interpolant F can be evaluated on scattered or gridded query locations.

Input Arguments

x

Vector of input coordinates the same size as v.

v

Vector of input values the same size as x.

X1, X2, ..., Xn

n n-dimensional arrays Xi that specify a grid. size(Xi) is size(V).

V

n-dimensional array of values associated with each grid point.

{xg1,xg2,...,xgn}

Cell array of grid vectors xgi that specify the grid in compact form.

Method

Interpolation method. Possible values are:

nearest

Nearest neighbor interpolation.

linear (default)

Linear, bilinear, trilinear,... interpolation.

spline

Spline interpolation.

pchip

Shape-preserving piecewise cubic interpolation (1-D only).

cubic

Cubic, bicubic, tricubic,.... For uniformly spaced data only.

Properties

GridVectors

Cell array containing grid vectors.

Values

Array of values associated with each grid point.

Method

Method used to interpolate data. Possible values are the same as for the Method input: nearest, linear (default), spline, pchip, or cubic.

Evaluation

The interpolant F can be evaluated on scattered or gridded query locations as follows:

Definitions

A gridded data set is an axis-aligned, ordered set of points.

A scattered data set consists of a set of points where the points have no structure among their relative locations.

Copy Semantics

Value. To learn how value classes affect copy operations, see Copying Objects in the MATLAB Programming Fundamentals documentation.

Indexing

Index-based editing of the properties of F are not supported. Instead, wholly replace the GridVectors or Values arrays as necessary. See Interpolation with the griddedInterpolant Class in the MATLAB Mathematics documentation for more information.

Examples

Interpolate to refine a grid-based sampling:

[X1, X2] = ndgrid(1:10,1:10);
V = X1.^2 + X2.^2;
F = griddedInterpolant(X1,X2,V, 'cubic');
[Xq1, Xq2] = ndgrid(1:0.5:10,1:0.5:10);
Vq = F(Xq1,Xq2);
mesh(Xq1,Xq2,Vq);

See Also

interp1 | interp2 | interp3 | interpn | meshgrid | ndgrid | TriScatteredInterp

How To

  


» Learn more
» Download free kit
» Get trial software

 © 1984-2012- The MathWorks, Inc.    -   Site Help   -   Patents   -   Trademarks   -   Privacy Policy   -   Preventing Piracy   -   RSS