0

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.

Cris Luengo
  • 55,762
  • 10
  • 62
  • 120
2one
  • 1,035
  • 3
  • 17
  • 36

2 Answers2

1

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:

GameOfThrows
  • 4,510
  • 2
  • 27
  • 44
  • Ah yes. That looks correct apart from the time/amplitude axis which need to be calibrated. Also I need to divide the single-sided amplitude spectrum by M(f). – 2one Apr 15 '16 at 09:19
  • There will always be some errors when transforming back from frequency domain to time domain, but this error should be quite small. If you find this answer useful, please accept it as the correct answer. – GameOfThrows Apr 15 '16 at 09:36
0

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. Try also this:

p(t) = real(ifft(fft(v(t)./M(f))))
M45ked
  • 1
  • 1
  • 4