fseries.m
来自「数字通信第四版原书的例程」· M 代码 · 共 25 行
M
25 行
function xx=fseries(funfcn,a,b,n,tol,p1,p2,p3)
%FSERIES Returns the Fourier series coefficients.
% XX=FSERIES(FUNFCN,A,B,N,TOL,P1,P2,P3)
% funfcn=The given function, in an m-file.
% It can depend on up to three parameters
% p1,p2, and p3. The function is given
% over one period extending from 'a' to 'b'
% xx=vector of length n+1 of Fourier Series
% Coefficients, xx0,xx1,...,xxn.
% p1,p2,p3=parameters of funfcn.
% tol=the error level.
j=sqrt(-1);
args=[];
for nn=1:nargin-5
args=[args,',p',int2str(nn)];
end
args=[args,')'];
t=b-a;
xx(1)=eval(['1/(',num2str(t),').*quad(funfcn,a,b,tol,[]',args]);
for i=1:n
newfun=['exp(-j*2*pi*x*(',int2str(i),')/(',num2str(t),')).*',funfcn];
xx(i+1)=eval(['1/(',num2str(t),').*quad(newfun,a,b,tol,[]',args]);
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?