从FFT中提取两个余弦函数之间的相位差

时间:2015-04-18 11:25:10

标签: fft dft cosine phase

我想从FFT中提取两个余弦函数之间的相位差。余弦函数是:x1(n)= cos(2 * pi fi n)和x2(n)= cos(2 * pi fi (n-m))。 基于DFT属性,我们有:

DFT(x1(n))= X1(f);
DFT(x2(n))= exp( (-j*2*pi*m*fi)/N )X1(f)

因此,DFT(x1(n))和DFT(x2(n))之间的相位差等于(-2 * pi m fi)/ N. 但是,从我的matlab代码中获得的结果是不同的!我的代码如下

 clc
clear all
Fs = 250;                    % Sampling frequency
T = 1/Fs;                     % Sample time
iniPhase=pi/6;
fin=120;
t=0:(1/Fs):2;
xu = cos(2*pi*fin*(t)) ;
xd = cos(2*pi*fin*(t)+iniPhase) ;
NFFT=length(xu);
NFFT=256;

Xu = fftshift(xu);
FFTXu = 2*fft(Xu,NFFT);
SpecXu=2*abs(FFTXu(1:NFFT/2+1));

Xd = fftshift(xd) ;
FFTXd = 2*fft(Xd,NFFT);
SpecXd=2*abs(FFTXd(1:NFFT/2+1));


[tt ind]=max(SpecXd(1:NFFT/2+1));

Phased=(angle( FFTXd));
Phaseu=(angle( FFTXu));
theta=(Phased(ind))-(Phaseu(ind));

1 个答案:

答案 0 :(得分:0)

根据傅立叶变换的移位特性,给出了x1(n)和x2(n)的光谱

DFT(x1(n))= X1(f);
DFT(x2(n))= exp( (-j*2*pi*m*fi)/N )X1(f);

然后,显然可以从

获得相位因子
DFT(x2)/DFT(x1), 

但不是

angle(DFT(x2) - DFT(x1)).