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

    %% Periodic and Aperiodic Sinc Functions
% The Dirichlet and sinc functions are related by $D_N(\pi x)=\mathop{\rm
% sinc}\nolimits(Nx/2)/\mathop{\rm sinc}\nolimits(x/2)$. Illustrate this
% fact for $N=6$.

xmax = 2;
x = linspace(-xmax,xmax,1001)';

N = 6;

yd = diric(x*pi,N);
ys = sinc(N*x/2)./sinc(x/2);

subplot(2,1,1)
plot(x,yd)
title('D_6(x*pi)')
subplot(2,1,2)
plot(x,ys)
title('sinc(6*x/2) / sinc(x/2)')

%%
% Repeat the calculation for $N=9$.

N = 9;

yd = diric(x*pi,N);
ys = sinc(N*x/2)./sinc(x/2);

subplot(2,1,1)
plot(x,yd)
title('D_9(x*pi)')
subplot(2,1,2)
plot(x,ys)
title('sinc(9*x/2) / sinc(x/2)')