从单面光谱+ Hermitian中恢复时间函数

问题描述 投票:2回答:3

我试图从它的单侧离散傅里叶变换得到一个真正的小波,w,它是一个列向量。根据该理论,负频率侧是正频率侧的复共轭,但在Matlab中实现它(使用ifft函数)让我头疼。

下面,我列出了一个小程序,它将阻尼正弦小波w转换为W的频域,然后提取正部分并用conj(flipud(W))对其进行扩充,但是它的逆FFT看起来像我的输入小波幅度用其他东西调制。但是,w = ifft(W,'symmetric')工作正常。任何有关确定问题的建议都将受到高度赞赏。

这是列表:

clc; clear all
% Genetate a damped sine wavelet
n = 100;
n2 = floor(n/2)+ 1;
dt = .25;
for i  = 1:n
    t = (i-1)*dt;
    w(i,1) = 100 * sin(t) * exp(-0.2*t);
end

figure; subplot(3,2,1);  plot(w);
title('The Signal')
%-------------------------------------
W1  = fft(w);                 % 2-sided
n2 = floor(n/2)+ 1;
W2  = fft(w,n2);              % 1-sided
subplot(3,2,3);plot(real(W2));
title('2-sided abs(W2)')
subplot(3,2,5);plot(imag(W2));
title('2-sided angle(W2)')
%-------------------------------------

w1 = ifft( W1 ) ;                 % Works fine
subplot(3,2,2); plot( w1);
title( ' w2 = ifft(W2);   (2-sided) ' );

% --------------------------------------
% Use the /symmetric/ option of ifft() with
% the single-sided spectrum

w2 = ifft(W2 , 'symmetric');  % 1-sided, works fine

subplot(3,2,4);plot(w2,'k');
title( 'w2 = ifft(W2, "symmetric" )')

% --------------------------------------
% Calculate the complex-cojugate of 1-sided W2
% (excluding the zero frequency point?!), flip it,
% and attach it to the tail of W2 col vector.

H  = flipud(conj(W2(2:n2)));
W3  = [W2 ; H];
w3 = ifft( W3 ) ;    % sourse of my migraine headache
% If you let n =1000 instead of the 100, the effect of
% amplitude-modulation-like effect is less and the output
% (bottom right graph)resembles the input wavelet but
% with a thicker line.
% If n=100 and W2(1:n2-1) in H = ... is used instead
% of the W2(2:n2), you'll get a flying bold eagle!


subplot(3,2,6);plot(w3,'k');
title('w3 = ifft([W2 ; H]')
%---end of the program-------------------
matlab fft spectrum ifft
3个回答
1
投票

问题出在这一行:

W2  = fft(w,n2);              % 1-sided

与隐含的假设不同,这将返回完整n2大小的FFT的第一个length(w)输出(如果是这样,它将给出预期的单侧频谱),该线反而返回完整的FFT(双侧频谱)序列w截断到n2样本。

然后修复计算W的完整FFT,然后选择结果的第一个n2样本,如更新后的代码所示:

W1 = fft(w);
W2 = W1(1:n2);

0
投票

以下工作,但我还没有弄清楚为什么前一个没有:

clc; clear all

% Genetate a damped sine wavelet
n = 101;  n2 = floor(n/2) + 1; dt = 0.25;

t = [(0:1:n-1)*dt]'; w = sin(t).*exp(-0.2*t);

figure; subplot(2,1,1);plot(w); 
title('The Wavelet')

W1   = fft(w);                % 2-sided
W2  = W1(1:n2);               % 1-sided

H  = flipud ( conj( W1(2:n2) ) );
W3 = [W2 ; H];  
w3 = ifft(W3);                % 2-sided

subplot(2,1,2); plot(w3); 
title('w3 = ifft( [ W3; H ]')

%---------- end of the program----------

0
投票

Down是一开始的示例代码的增强版本。根本问题是关于最后的ifft。考虑使用(pi./df)缩放实部。

您的“扩充代码”如下:

close all; clear all; clc; 

% Genetate a damped sine wavelet
n = 512;  n2 = floor(n/2) + 1; dt = 0.25; 
fs=1/dt;   % Digitised data should ever have a sampling rate -right! 

f=linspace(0,fs,n); % Your frequency axis 
df=mean(diff(f)); % Your incrementation on the frequency axis
fc=f(12); % Just to get a monochromatic data in time, frequency is needed    
          % f(12) just to obey the sampling constraints not more than f(n/2+1)


t = [(0:1:n-1)*dt]; w = cos(2.*pi.*fc.*t).*exp(-0.2*t);

figure; subplot(2,1,1);plot(t,w); 
title('The Wavelet')

W1   = fft(w)./n;                % 2-sided
W2  = W1(1:n2);               % 1-sided

H  = fliplr (conj(W1(2:n2-1))); % Intended to stick with the data length...
W3 = [W2 , H];  
w3 = (pi./df).*real(ifft(W3));                % 2-sided (see the scaling)

subplot(2,1,2); plot(w3); 
title('w3 = ifft( [ W3; H ]')

fprintf('Data size at the beginning:\n');
size(w)
fprintf('Final sata size:\n');
size(w3)
© www.soinside.com 2019 - 2024. All rights reserved.