简体   繁体   English

使用FFT过滤正弦波

[英]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 : 我正在尝试在Matlab中编写一个代码,该代码将一个或多个正弦波施加噪声,并尝试使用以下算法对其进行过滤:

  • first i take the input and place it in a vector 首先,我将输入内容放入向量中

  • then i apply fft() to that vector and abs() to that fft 然后我将fft()应用于该矢量,并将abs()应用于该fft
    - example if 'x' is the vector in which wave is stored then -例如,如果“ x”是存储波的矢量,则
    - y= abs(fft(x)) -y = abs(fft(x))

  • now in 'y' i make all the elements less than a certain threshold value 0 现在在“ y”中,我使所有元素小于某个阈值0

  • then apply the ifft() function to get the filtered signal lets say 'x1' 然后应用ifft()函数获取滤波后的信号,让我们说“ 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?? 但是即使正弦波我也得到了最后一个波,但它是异相的(见图)。是因为我将abs()应用于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. 您将FFT结果的绝对值分配给y,因此得到REAL值。 Doing ifft() on that simply assumes imaginary-parts are zero, hence the phase-shift. 对此做ifft()只是假设虚部为零,因此是相移。

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

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