📄 diric.m
字号:
function y=diric(x,N)
%DIRIC Dirichlet, or periodic sinc function
% Y = DIRIC(X,N) returns a matrix the same size as X whose elements
% are the Dirichlet function of the elements of X. Positive integer
% N is the number of equally spaced extrema of the function in the
% interval 0 to 2*pi.
%
% The Dirichlet function is defined as
% d(x) = sin(N*x/2)./(N*sin(x/2)) for x not a multiple of 2*pi
% +1 or -1 for x a multiple of 2*pi. (depending on limit)
% Author(s): T. Krauss, 1-14-93
% Copyright (c) 1988-98 by The MathWorks, Inc.
% $Revision: 1.11 $ $Date: 1997/11/26 20:12:58 $
error(nargchk(2,2,nargin));
if round(N)~=N | N<1 | prod(size(N))~=1,
error('Requires N to be a positive integer.');
end
y=sin(.5*x);
i=find(abs(y)>1e-12); % set where x is not divisible by 2 pi
j=1:length(x(:));
j(i)=[]; % complement set
y(i)=sin((N/2)*x(i))./(N*y(i));
y(j)=sign(cos(x(j)*((N+1)/2)));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -