www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/InterpolateUsingCubicMethodExample.m
%% Interpolate Using Cubic 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$. %% % 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 using the |'cubic'| interpolation % method. Then plot the results. Vq = interp3(X,Y,Z,V,Xq,Yq,Zq,'cubic'); figure slice(Xq,Yq,Zq,Vq,[6 9],2,0); shading flat