Documentation

diric

Dirichlet or periodic sinc function

Syntax

y = diric(x,n)

Description

y = diric(x,n) returns a vector or array y the same size as x. The elements of y are the Dirichlet function of the elements of x. n must be a positive integer.

Examples

collapse all

Dirichlet Function

Compute and plot the Dirichlet function between $-2\pi$ and $2\pi$ for N = 7 and N = 8.

x = linspace(-2*pi,2*pi,301);

d7 = diric(x,7);
d8 = diric(x,8);

subplot(2,1,1)
plot(x/pi,d7)
ylabel('N = 7')
title('Dirichlet Function')

subplot(2,1,2)
plot(x/pi,d8)
ylabel('N = 8')
xlabel('x / \pi')

The function has a period of $2\pi$ for odd N and $4\pi$ for even N.

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)')

Diagnostics

If n is not a positive integer, diric gives the following error message:

Requires n to be a positive integer.

More About

collapse all

Dirichlet Function

The Dirichlet function, or periodic sinc function, is

DN(x)={sin(Nx/2)Nsin(x/2)x2πk,k=0,±1,±2,±3,...(1)k(N1)x=2πk,k=0,±1,±2,±3,...

for any nonzero integer N. This function has period 2π for odd N and period 4π for even N. Its peak value is 1, and its minimum value is –1 for even N. The magnitude of the function is 1/N times the magnitude of the discrete-time Fourier transform of the N-point rectangular window.

Introduced before R2006a

Was this topic helpful?