# interpolate2d (MathScript RT Module Function)

LabVIEW 2012 MathScript RT Module Help

Edition Date: June 2012

Part Number: 373123C-01

»View Product Info

Owning Class: approximation

Requires: MathScript RT Module

## Syntax

z2 = interpolate2d(z1, times)

z2 = interpolate2d(z1, x2, y2)

z2 = interpolate2d(x1, y1, z1, x2, y2)

z2 = interpolate2d(x1, y1, z1, x2, y2, method)

Legacy Name: `interp2`

## Description

Interpolates z-values based on sample data using a specified method.

Examples

## Inputs

Name Description
z1 Specifies the sample z-values. z1 is a real, double-precision matrix.
times Specifies the number of times LabVIEW must interpolate recursively between the given points. Specifically, LabVIEW adds 2^(times)-1 points between each given set of points. times is an integer.
x2 Specifies the x-values at which you want to interpolate z-values. x2 is a row vector or a matrix of real, double-precision numbers.
y2 Specifies the y-values at which you want to interpolate z-values. If x2 is a row vector, y2 must be a real, double-precision column vector. If x2 is a matrix, y2 must be a real, double-precision matrix of the same size as x2.
x1 Specifies the sample x-values. If you do not specify x1, LabVIEW sets x1 to the values of 0 ... m- 1 where [m, n] equals size(z1). x1 is a real, double-precision vector.
y1 Specifies the sample y-values. If you do not specify y1, LabVIEW sets y1 to the values of 0 ... n- 1 where [m, n] equals size(z1). y1 is a real, double-precision vector.
method Specifies the interpolation method to use. method is a string that accepts the following values.

 'cubic' Performs cubic Hermite interpolation. 'linear' (default) Performs linear interpolation. 'nearest' Chooses the z1 value corresponding to the (x1, y1) value that is nearest to the current z2 value. LabVIEW sets the interpolated value to the nearest data point. 'spline' Performs spline interpolation.

## Outputs

Name Description
z2 Returns the z-values interpolated at the values of (x2, y2). z2 is a real, double-precision matrix.

## Details

The following table lists the support characteristics of this function.

 Supported in the LabVIEW Run-Time Engine Yes Supported on RT targets Yes Suitable for bounded execution times on RT Not characterized

## Examples

Z1 = zeros(10, 10);
for i = 1:10
for k = 1:10
Z1(i, k) = i^2+4*i+3*k^4-2*k;
end
end
Z2 = interpolate2d(Z1, 2);