Contents Previous Next Subchapters

Two Dimensional Piecewise Bilinear Interpolation (Mlmode)
Syntax interp2(xzyzzxiyi)
See Also interp2 , interp , smospl

Description
Returns the values of the piecewise bilinear interpolant that has the value z(i,j) at the point (yz(i, 1), xz(1, j)) for i = 1 to the row dimension of yz and j = 1 to the column dimension of xz. The (i,j)-th element of the return value is the value of the interpolant at (yi(i, 1), xi(1, j)) for i = 1 to the row dimension of yi and j = 1 to the column dimension of xi. The return value has the same type as z, the same row dimension as yi, and the same column dimension as xi. Both the row and column dimensions of z must be greater than 1. The matrix yz has the same number of rows as z. The matrix xz has the same number of columns as z.

The vectors yz(:,1), xz(1,:), yi(:,1), xi(:,1) are integer, real, or double-precision. In addition, the vectors yz(:,1), xz(1,:), are strictly monotone increasing or decreasing. If z is complex, the return value is complex. If all the arguments are real, the return value is real. Otherwise the return value is double-precision.

Example
The example below uses interp2 to interpolate the function x y between 1 and 5 in both the x and y directions. The interpolation exactly matches the function because x y is bilinear.

If in Mlmode you enter
     xz = [1. , 5.];
     yz = xz';
     z  = yz * xz;
     xi = [1. ,  2. ,  3. ,  4. ,  5.];
     yi = xi';
     interp2(xz, yz, z, xi, yi)
O-Matrix will respond
     {
     [ 1 , 2 , 3 , 4 , 5 ]
     [ 2 , 4 , 6 , 8 , 10 ]
     [ 3 , 6 , 9 , 12 , 15 ]
     [ 4 , 8 , 12 , 16 , 20 ]
     [ 5 , 10 , 15 , 20 , 25 ]
     }

Reference
A function f(x,y) is bilinear if its second partial derivative with respect to x and its second partial derivative with respect to y is zero. The interpolating function is continuous and it is bilinear over rectangles of the form
     {(x,y) : xz  < x < xz   and  yz  < y < yz  }
                i         i+1        i         i+1