简体   繁体   English

MATLAB:使用ifft提取原始信号

[英]MATLAB: Using ifft to extract original signal

I have a time varying signal (with a fundamental frequency and a number of harmonics) which I have computed the fft() of and then divide this by a frequency dependent sensitivity, M(f) . 我有一个随时间变化的信号(具有基本频率和许多谐波),该信号已经计算了fft() ,然后将其除以频率相关的灵敏度M(f) I then want to convert back to the time domain using ifft() to get the time varying signal but ifft() does not seem to work ie: 然后,我想使用ifft()转换回时域以获得时变信号,但ifft()似乎不起作用,即:

p(t) = ifft(fft(v(t)./M(f))

Is ifft() not doing what I think here? ifft()没有按照我的想法做吗?

****FOLLOW UP*** ****跟进***

I have written the following code to try to understand this: 我已经编写了以下代码以尝试了解这一点:

% v(t)

t=0:0.1:10;
a=sin(t);

subplot(1,5,1); plot(t,a); 
title('1. time domain'); 
xlabel('t [s]')
ylabel('p.d. [v]')
hold on;

% fft(v(t))

T = t(2);                       % Sampling period
Fs=1/T;
L = length(t);                  % Length of signal
Y = fft(a);
P2 = abs(Y/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;

subplot(1,5,2); plot(f,P1);
title('2. frequency domain (fft(vt))')
xlabel('f [Hz]')
ylabel('magnitude')

%frequency responce (sensitivity), M(f)

resp=ones(1,length(f)); %1=1

subplot(1,5,3); plot(f,resp);
title('3. Simulated sensitivity (M(f))')
xlabel('f [Hz]')
ylabel('v / p')

% fft(v(t))./M(f)

fftResp=P1./resp;

subplot(1,5,4); plot(f,fftResp);
title('4. fft(v(t))./M(f)')
xlabel('f [Hz]')
ylabel('fft(v(t)) / M(f)')

%Inverse fft, p(t) = ifft(fft(v(t)./M(f)))

pt = real(ifft(fftResp));

subplot(1,5,5); plot(pt);
title('5. time domain (ifft)')
xlabel('t [s]')
ylabel('p.d. [p]')

results: https://www.dropbox.com/s/18tqeyqey2pc5te/SOfigure.png?dl=0 结果: https : //www.dropbox.com/s/18tqeyqey2pc5te/SOfigure.png?dl=0

With the M(f) = 1 at all frequencies I expect the final ifft() result (fig. 5) to equal the initial time domain signal (fig. 1) but it does not? 在所有频率下M(f)= 1时,我希望最终的ifft()结果(图5)等于初始时域信号(图1),但不是吗? The second FFT (fig. 3) is equivalent to the first (fig. 2) which is correct. 第二个FFT(图3)等效于第一个FFT(图2)。

Your error stems from your understanding of abs and real they are NOT the same. 您的错误源于您对abs的理解,但real它们并不相同。 The error is found in this line: 在此行中发现错误:

P2 = abs(Y/L);

Here, Y is the complex fft result, L is a scalar, you need to use real instead of abs . 在这里,Y是复数fft结果,L是标量,您需要使用real而不是abs

P2 = real(Y/L);

and this results: 结果:

Maybe you should use ./ operator. 也许您应该使用./运算符。 It divide every corresponding items in vectors: 它将向量中的每个对应项划分为:

p(t) = ifft(fft(v(t)./M(f)))

It should works. 它应该工作。 Sometime ifft compute complex signal with small imaginary part as the output. 有时,ifft计算虚部很小的复杂信号作为输出。 Try also this: 也试试这个:

p(t) = real(ifft(fft(v(t)./M(f))))

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM