www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/InterpolateUsingDefaultMethodExample.m

    %% Interpolate Using Default Method  

% Copyright 2015 The MathWorks, Inc.


%% 
% Load the points and values of the flow function, sampled at 10 points
% in each dimension. 
[X,Y,Z,V] = flow(10); 

%%
% The |flow| function returns the grid in the arrays, |X|, |Y|, |Z|. The
% grid covers the region, $0.1\le{X}\le{10}$, $-3\le{Y}\le{3}$, $-3\le{Z}\le{3}$, and the
% spacing is $\Delta{X} = 0.5$, $\Delta{Y} = 0.7$, and $\Delta{Z} = 0.7$.  

%% 
% Now, plot slices through the volume of the sample at: |X=6|, |X=9|, |Y=2|,
% and |Z=0|. 
figure
slice(X,Y,Z,V,[6 9],2,0);
shading flat     

%% 
% Create a query grid with spacing of 0.25. 
[Xq,Yq,Zq] = meshgrid(.1:.25:10,-3:.25:3,-3:.25:3);  

%% 
% Interpolate at the points in the query grid and plot the results using
% the same slice planes. 
Vq = interp3(X,Y,Z,V,Xq,Yq,Zq);
figure
slice(Xq,Yq,Zq,Vq,[6 9],2,0);
shading flat