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

    %% Interpolation of Complex Values  

% Copyright 2015 The MathWorks, Inc.


%% 
% Define a set of sample points. 
x = 1:10;  

%% 
% Define the values of the function, $v(x) = 5x + x^2i$,
% at the sample points. 
v = (5*x)+(x.^2*1i);  

%% 
% Define the query points to be a finer sampling over the range of |x|. 
xq = 1:0.25:10;  

%% 
% Interpolate |v| at the query points. 
vq = interp1(x,v,xq);  

%% 
% Plot the real part of the result in red and the imaginary part in blue. 
figure
plot(x,real(v),'*r',xq,real(vq),'-r');
hold on
plot(x,imag(v),'*b',xq,imag(vq),'-b');