| MATLAB Function Reference | Search  Help Desk |
| interp3 | Examples See Also |
Three-dimensional data interpolation (table lookup)
Syntax
VI = interp3(X,Y,Z,V,XI,YI,ZI) VI = interp3(V,XI,YI,ZI) VI = interp3(V,ntimes) VI = interp3(...,method)
Description
VI = interp3(X,Y,Z,V,XI,YI,ZI)
interpolates to find VI, the values of the underlying three-dimensional function V at the points in matrices XI,YI and ZI. Matrices X,Y and Z specify the points at which the data V is given. Out of range values are returned as NaN.
XI, YI, and ZI can be matrices, in which case interp3 returns the values of Z corresponding to the points (XI(i,j),YI(i,j),ZI(i,j)). Alternatively, you can pass in the vectors xi, yi, and zi. Vector arguments that are not the same size are interpreted as if you called meshgrid.
VI = interp3(V,XI,YI,ZI)
assumes X=1:N, Y=1:M, Z=1:P where [M,N,P]=size(V).
VI = interp3(V,ntimes)
expands V by interleaving interpolates between every element, working recursively for ntimes iterations. The command interp3(V,1) is the same as interp3(V).
VI = interp3(...,method)
specifies alternative methods:
'spline' for cubic spline interpolation
Discussion
All the interpolation methods require thatX,Y and Z be monotonic and have the same format ("plaid") as if they were produced by meshgrid. Variable spacing is handled by mapping the given values in X,Y,Z,XI,YI and ZI to an equally spaced domain before interpolating. For faster interpolation when X, Y, and Z are equally spaced and monotonic, use the methods '*linear', '*cubic', '*spline', or '*nearest'.
Examples
To generate a course approximation offlow and interpolate over a finer mesh:
[x,y,z,v] = flow(10); [xi,yi,zi] = meshgrid(.1:.25:10, -3:.25:3, -3:.25:3); vi = interp3(x,y,z,v,xi,yi,zi); % V is 31-by-41-by-27 slice(xi,yi,zi,vi,[6 9.5],2,[-2 .2]) shading flat
See Also
interp1, interp2, interpn, meshgrid