Mathematics Previous page   Next Page

Two-Dimensional Interpolation

The function interp2 performs two-dimensional interpolation, an important operation for image processing and data visualization. Its most general form is

Z is a rectangular array containing the values of a two-dimensional function, and X and Y are arrays of the same size containing the points for which the values in Z are given. XI and YI are matrices containing the points at which to interpolate the data. method is an optional string specifying an interpolation method.

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

All of these methods require that X and Y be monotonic, that is, either always increasing or always decreasing from point to point. You should prepare these matrices using the meshgrid function, or else be sure that the "pattern" of the points emulates the output of meshgrid. In addition, each method automatically maps the input to an equally spaced domain before interpolating. If X and Y are already equally spaced, you can speed execution time by prepending an asterisk to the method string, for example, '*cubic'.


Previous page  One-Dimensional Interpolation Comparing Interpolation Methods Next page

© 1994-2005 The MathWorks, Inc.