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)
. 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 i.e.:
p(t) = ifft(fft(v(t)./M(f))
Is ifft()
not doing what I think here?
****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
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? The second FFT (fig. 3) is equivalent to the first (fig. 2) which is correct.
Your error stems from your understanding of abs
and real
they are NOT the same. 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
.
P2 = real(Y/L);
and this results: