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

    %% Interpolate a Sum of Sinusoids
%%
% *Note*: This example runs only in R2016b or later. If you are using an
% earlier release, replace each call to the function with the equivalent
% |step| syntax. For example, myObject(x) becomes step(myObject,x).

%%
% Interpolate a sum of sinusoids with FIR interpolation and |Input Port|
% as the source of interpolation points.
Fs = 1000;
t = 0:(1/Fs):0.1-(1/Fs);
x = cos(2*pi*50*t)+0.5*sin(2*pi*100*t);
x1 = x(1:4:end);
I = 1:(1/4):length(x1);
H = dsp.Interpolator('Method','FIR',...
'FilterHalfLength',3,'InterpolationPointsSource','Input Port');
y = H(x1',I');
stem(I,y,'r'); hold on;
axis([0 25 -2 2]);
stem(x1,'b','linewidth',2);
legend('Interpolated Signal','Original',...
'Location','Northeast');