Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 工程数学软件 > MATLAB论坛
MATLAB论坛 一切MATLAB相关问题在此讨论。
回复
 
主题工具 显示模式
旧 2007-08-10, 10:16   #1
shihong
初级会员
 
注册日期: 2007-08-10
帖子: 1
声望力: 0
shihong 正向着好的方向发展
默认 【求助】请大家帮忙翻译一段matlab程序

我想把这段程序换成C语言,但由于没学过matlab,所有有些地方搞不明白,希望matlab高手帮忙说明和注释一下,万分感谢,在线等待!

function S=fft_accumulation_method(x,y,N,a,g,L)
%
% FFT_ACCUMULATION_METHOD
% estimate the spectral correlation density using the FFT
% accumulation method
% Reference:
% Roberts R. S., Brown, W. A. and Loomis, H. H.
% "Computationally efficient algorithms for cyclic
% spectral analysis" IEEE Signal Processing Magazine
% 8(2) pp38-49 April 1991
%
% Input parameters are:
% x,y signals
% N length of time window used for estimating frequency
% segments (should be power of 2)
% a window used for smoothing segments
% g window for smoothing correlation
% L decimation factor
%
% USAGE S=fft_accumulation_method(x,y,N,a,g,L)
%
% e.g s=fft_accumulation_method(s1,s1,64,'hamming','hamming',1)

if ~exist('L')
L=1;
end

lx=length(x);
if (length(y)~=lx)
error('Time series x and y must be same length')
end


n=0:floor((lx-N)/L);
ln=length(n);
a=feval(a,N)';
g=feval(g,ln)';
g=g/sum(g);
a=a/sum(a);

X=zeros(N,ln);
Y=zeros(N,ln);

Ts=1/N;

for i=1:ln
n_r=n(i)*L+(1:N);
X(:,i)=fftshift(fft(a.*x(n_r)))';
Y(:,i)=fftshift(conj(fft(a.*y(n_r))))';
end


lnd2=floor(ln/2);
lnd4=floor(ln/4)+1;
ln3d4=lnd4+lnd2-2;
S=zeros(2*N-1,lnd2*(N+1));

for alpha=-N/2+1:N/2-1
for f=-N/2:N/2-1
f1=f+alpha;
f2=f-alpha;
if ((abs(f1)<N/2)&(abs(f2)<N/2))
f1=f1+N/2;
f2=f2+N/2;
fsh=fftshift(fft(g.*X(f1,.*Y(f2,));
S(2*f+N,(alpha+N/2)*lnd2+(1:lnd2-1))=fsh(1,lnd4:ln3d4);
end
f1=f+alpha;
f2=f-alpha+1;
if ((abs(f1)<N/2)&(abs(f2)<N/2))
f1=f1+N/2;
f2=f2+N/2;
fsh=fftshift(fft(g.*X(f1,.*Y(f2,));
S(2*f+N+1,(alpha+N/2)*lnd2+(1:lnd2-1)-lnd4+1)=fsh(1,lnd4:ln3d4);
end
end
end
shihong 当前离线   回复时引用此帖
回复

主题工具
显示模式

发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛禁用 HTML 代码



所有时间均为北京时间。现在的时间是 11:23


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.