主要内容

diric

狄利克雷或周期性正弦函数

说明

y = diric(x,n) 返回在输入数组 x 的元素处计算的次数为 n狄利克雷函数

示例

示例

全部折叠

计算并绘制狄利克雷函数在 -2π2π 之间(对于 N = 7 和 N = 8)的图。对于奇数 N,该函数的周期为 2π,对于偶数 N,周期为 4π

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

Figure contains 2 axes objects. Axes object 1 with title Dirichlet Function, ylabel N = 7 contains an object of type line. Axes object 2 with xlabel x / \pi, ylabel N = 8 contains an object of type line.

狄利克雷和正弦函数的相关性表示为 DN(πx)=sinc(Nx/2)/sinc(x/2)。显示 N=6 时的此关系。通过将正弦函数的比率指定为 (-1)k(N-1)(对于 x=2k,其中 k 是整数)来避免不确定表达式。

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

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

Figure contains 2 axes objects. Axes object 1 with title D indexOf 6 baseline (x*pi) contains an object of type line. Axes object 2 with title sinc(6*x/2) / sinc(x/2) contains an object of type line.

重复 N=13 的计算。

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

subplot(2,1,1)
plot(x,yd)
title('D_{13}(x*pi)')
subplot(2,1,2)
plot(x,ys)
title('sinc(13*x/2) / sinc(x/2)')

Figure contains 2 axes objects. Axes object 1 with title D indexOf 13 baseline (x*pi) contains an object of type line. Axes object 2 with title sinc(13*x/2) / sinc(x/2) contains an object of type line.

输入参数

全部折叠

输入数组,指定为实数标量、向量、矩阵或 N 维数组。当 x 为非标量时,diric 是按元素运算。

数据类型: double | single

函数次数,指定为正整数标量。

数据类型: double | single

输出参量

全部折叠

输出数组,以实数值标量、与 x 大小相同的向量、矩阵或 N 维数组形式返回。

详细信息

全部折叠

扩展功能

全部展开

C/C++ 代码生成
使用 MATLAB® Coder™ 生成 C 代码和 C++ 代码。

版本历史记录

在 R2006a 之前推出