%% Evaluate Outside the Domain of X, Y, and Z
% Create the grid vectors, x, y, and z. These vectors define the points associated with values in V.

x = 1:100;
y = (1:50)';
z = 1:30;

%
% Define the sample values to be a 50-by-100-by-30 random number array, V. Use the rand function to create the array.

rng('default')
V = rand(50,100,30);

%
% Evaluate V at three points outside the domain of x, y, and z. Specify extrapval = -1.

xq = [0 0 0];
yq = [0 0 51];
zq = [0 101 102];
vq = interp3(x,y,z,V,xq,yq,zq,'linear',-1)

% All three points evaluate to -1 because they are outside the domain of x, y, and z.
% Copyright 2015 The MathWorks, Inc.