1

Rebuilding original signal from frequencies, amplitude, and phase obtained after doing an fft.

Greetings

I'm trying to rebuild a signal from the frequency, amplitude, and phase obtained after I do an fft of a signal, but when I try and combine the fft data (frequency, amplitude, and phase) back to see if I get a similar signal, the pattern is a little off. I think it has to do with my formula which may be a little incorrect.

The formula I'm using to combine the data is:

amplitude*sin(2*pi*time*frequency+phase)+amplitude*cos(2*pi*time*frequency+phase);

Please note: At the moment I don't want to use IFFT due to the fact that I will be editing the amplitude and frequencies before the calculations are done

An image of the plot is below. The top one is the original signal and the bottom one is the signal created with the equation. If you want to know I'm using matlab but I think the problem is with the equation. enter image description here

tia

Rick T
  • 3,349
  • 10
  • 54
  • 119
  • Can you explain this a bit better? The equation will just give a single sine wave but you clearly have something more complicated going on here. Do you have a series of FFTs so that the amplitude, freq and phase keep changing? – AAT Jun 01 '11 at 22:14
  • @AAT amplitude, frequency etc. probably are matrices – tstenner Jun 01 '11 at 22:26
  • @tstenner - good call, it's very likely so - perhaps Rick will confirm. – AAT Jun 01 '11 at 22:28
  • have you at least tried ifft to see what you get (to compare to your routine)? – Rasman Jun 01 '11 at 22:34
  • @AAT yes amplitude, frequency and phase are matrices. – Rick T Jun 01 '11 at 23:24
  • @Rasman yes I've tried IFFT and it does work. But I will be editing the frequencies and amplitudes that's why I'm using the equation which maybe causing the issue – Rick T Jun 01 '11 at 23:25
  • You can edit the frequencies and amplitudes, and still use the IFFT. – Cris Luengo Jan 17 '18 at 22:53

2 Answers2

3

The IFFT is an efficient implementation of the following transformation:

       N-1
x[n] = SUM X[k] exp(j*2*pi*n*k/N)
       k=0

where X[k] are your FFT results (complex amplitudes), and x[n] are your time-domain samples. For real-only inputs, this can be rewritten in terms of cos and sin (or in terms of cos with a phase term), but it's usually easier just to stick with the complex representation.

[This can be heavily vectorised, but I'll leave that up to you!]

Oliver Charlesworth
  • 267,707
  • 33
  • 569
  • 680
1

I don't see why you want both a sin and a cos term in your equation: this should do it...

amplitude*sin(2*pi*time*frequency+phase);

Using both sin and cosine terms will, unless there is something odd about the FFT, cause scaling issues and a phase shift. However I do not know if that would explain the distortion you've seen. That may be due to something to do with the FFT block sizes you have used.

AAT
  • 3,286
  • 1
  • 22
  • 26