Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Noise Filter In Matlab

  1. Feb 22, 2012 #1
    I am trying to create noise that has similar spectral properties of a recorded tapping sound (so that I can mask the tapping sound). I was thinking that if I generate noise, and then multiply the fft of the noise by the fft of the tap sound, it would sort of "filter" the noise to the desired fft.

    First off, I'm not 100% sure on how to create the noise. I am currently using:
    noise=complex(randn(m, 1), randn(m, 1)*sqrt(p/2)
    because I found an example online. I'm not really sure if this is white gaussian noise, or what. I'm also not sure what the m and p are.

    Secondly, if I use abs(fft(noise)) and then multiple that by the abs(fft(TapSound)), I get the desired fft that I want (I think...?). but then if I use ifft to get back to the sound wave, won't that be missing important data because I used an absolute value?

    Any help you can give me would be appreciated. Thank you!
  2. jcsd
  3. Feb 23, 2012 #2
    The function randn will return a value according to the Gaussian distribution specified by the parameters, but I don't think a vector of Gaussian random complex numbers is what you want (m is the length of the vector). The time domain values of the noise should be only real, and the frequency domain representation should be white. In other words, the magnitude of the frequency domain function should be flat or constant.

    The MatLab function wgn can be used to create a vector of white noise.
Share this great discussion with others via Reddit, Google+, Twitter, or Facebook