diric
R2026bDirichlet or periodic sinc function
Syntax
Description
returns the Dirichlet Function of degree
y = diric(x,n)n evaluated at the elements of the input array
x.
Examples
Compute and plot the Dirichlet function between and for N = 7 and N = 8. The function has a period of for odd N and for even N.
x = linspace(-2*pi,2*pi,301); d7 = diric(x,7); d8 = diric(x,8); tiledlayout("flow") nexttile plot(x/pi,d7) ylabel("N = 7") title("Dirichlet Function") nexttile plot(x/pi,d8) ylabel("N = 8") xlabel("x / \pi")

The Dirichlet and sinc functions are related by . Show this relationship for . Avoid indeterminate expressions by specifying that the ratio of sinc functions is for , where is an integer.
xmax = 4; x = linspace(-xmax,xmax,1001)'; N = 6; yd = diric(x*pi,N); ys = sinc(N*x/2)./sinc(x/2); ys(~mod(x,2)) = (-1).^(x(~mod(x,2))/2*(N-1)); tiledlayout("flow") nexttile plot(x,yd) title("D_6(x*pi)") nexttile plot(x,ys) title("sinc(6*x/2) / sinc(x/2)")

Repeat the calculation for .
N = 13; yd = diric(x*pi,N); ys = sinc(N*x/2)./sinc(x/2); ys(~mod(x,2)) = (-1).^(x(~mod(x,2))/2*(N-1)); tiledlayout("flow") nexttile plot(x,yd) title("D_{13}(x*pi)") nexttile plot(x,ys) title("sinc(13*x/2) / sinc(x/2)")

Input Arguments
Input array, specified as a real scalar, vector, matrix, or N-D
array. When x is nonscalar, diric is an
element-wise operation.
Data Types: double | single
Function degree, specified as a positive integer scalar.
Data Types: double | single
Output Arguments
Output array, returned as a real-valued scalar, vector, matrix, or
N-D array of the same size as x.
More About
The Dirichlet function, or periodic sinc function, is
for any nonzero integer N.
This function has period 2π for odd N and period 4π for even N. Its maximum value is 1 for all N, 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.
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.
GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.
The diric
function fully supports thread-based environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
Version History
Introduced before R2006aYou can use diric in thread-based
environments. For more information, see Run MATLAB Functions in Thread-Based Environment.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)