声振论坛

 找回密码
 我要加入

QQ登录

只需一步,快速开始

查看: 1169|回复: 0

[综合讨论] 请教大家一个小程序

[复制链接]
发表于 2006-7-9 23:57 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?我要加入

x
此程序计算信号傅立叶系数,最后一个for循环我看不懂,请高人帮我注释一下啊?
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);
args0=[];
for nn=1:nargin-5
  args0=[args0,',p',int2str(nn)];
end
args=[args0,')'];
t=b-a;
xx(1)=eval(['1/(',num2str(t),').*quad(funfcn,a,b,tol,[]',args]) ;

for i=1:n
  new_fun = 'exp_fnct' ;
  args=[',', num2str(i), ',', num2str(t), args0, ')' ] ;
  xx(i+1)=eval(['1/(',num2str(t),').*quad(new_fun,a,b,tol,[],funfcn',args]);
end:(
回复
分享到:

使用道具 举报

您需要登录后才可以回帖 登录 | 我要加入

本版积分规则

QQ|小黑屋|Archiver|手机版|联系我们|声振论坛

GMT+8, 2024-9-25 09:34 , Processed in 0.051348 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表