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

    %% Interpolation of Complex Scattered Data
% This example shows how to interpolate scattered data when the value at each sample location is complex.

% Copyright 2015 The MathWorks, Inc.


%%
% Create the sample data.
X = -3 + 6 .* gallery('uniformdata',[250 2],0);
V = complex(X(:,1).*X(:,2), X(:,1).^2 + X(:,2).^2);

%%
% Create the interpolant.
F = scatteredInterpolant(X,V);

%%
% Create a grid of query points and evaluate the interpolant at the grid points.
[Xq,Yq] = meshgrid(-2.5:0.125:2.5);
Vq = F(Xq,Yq);

%%
% Plot the real component of |Vq|.
VqReal = real(Vq);
figure
surf(Xq,Yq,VqReal);
xlabel('X');
ylabel('Y');
zlabel('Real Value - V');
title('Real Component of Interpolated Value');

%%
% Plot the imaginary component of |Vq|.
VqImag = imag(Vq);
figure
surf(Xq,Yq,VqImag);
xlabel('X');
ylabel('Y');
zlabel('Imaginary Value - V');
title('Imaginary Component of Interpolated Value');