简体   繁体   中英

Filtering a sinusoidal wave with FFT

I am trying to write a code in Matlab which takes a one or sum of sinosudal waves imposed with noise and try to filter it using the following algo :

  • first i take the input and place it in a vector

  • then i apply fft() to that vector and abs() to that fft
    - example if 'x' is the vector in which wave is stored then
    - y= abs(fft(x))

  • now in 'y' i make all the elements less than a certain threshold value 0

  • then apply the ifft() function to get the filtered signal lets say 'x1'

but the final wave i get even though a sinusoidal wave it is out phase (see the graph).is it because iam applying abs() to the fft??
But the material which i got this algo from doesn't discuss about this.
Do i need to apply any other filter so that i get the actual wave??

here is the plot of the two waves: one i got from above procedure and the other the actual wave which is a sine wave with no noise: my graph

see how my filtered wave and the actual wave are out of phase how to correct it ??

if you cannot understand the question or have anything you want to ask me please comment i will try to explain it.

You are assigning the absolute-values of the FFT result to y, hence you get REAL values. Doing ifft() on that simply assumes imaginary-parts are zero, hence the phase-shift.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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