Simple FIR Filtering on some white noise

Hi All,
A really stupid question for ya. I appologize in a advance that I am so confused on something this easy.
I am trying to get an FIR lowpass filter to work on some white noise I generated in Audacity. I have already gotten the IIR version of this filter to work using the "butter" command, but I can't seem to get the FIR one to work.
I call in the white noise using "audioread"
[signal,fs] = audioread('white.wav');
Wn = 60/(fs/2); %Cutoff frequency of 60 Hz (normalized)
and then do the following:
%FIR Filter [b_fir,a_fir] = fir1(4,Wn,'high');
signal_fir = filter(b_fir,a_fir,signal);
audiowrite('white_60Hz_fir.wav',signal_fir,fs);
The signal that comes out (signal_fir) doesn't seem to have anything done to it.....
Comments on what I'm doing wrong please.
Thanks in advance

3 comentarios

WAJID
WAJID el 24 de Ag. de 2014
i need complete code ..plz send to me
Image Analyst
Image Analyst el 24 de Ag. de 2014
WAJID - that kind of request rarely works. Why don't you read this and then post another question of your own. Reference this post and tell why the answers given here don't work for you. Supply your own data and any background information necessary to let people develop an answer for you.
WAJID
WAJID el 24 de Ag. de 2014
in simulink i enter a white noise to a signal but how to filter it by fir filter?

Iniciar sesión para comentar.

 Respuesta aceptada

Honglei Chen
Honglei Chen el 19 de Mzo. de 2014
Editada: Honglei Chen el 19 de Mzo. de 2014
Your command
fir1(4,Wn,'high')
designs a highpass instead of a lowpass. Also, for FIRs, I believe fir1 only returns one output, i.e., b_fir. The denominator is always 1 for FIRs, so you could do
filter(b_fir,1,signal)
HTH

5 comentarios

Sushma Chandran
Sushma Chandran el 19 de Mzo. de 2014
I actually meant to use a high pass so I mis-typed in my message. Thanks for catching that. The fs of my signal is 48000. If I use a fir1(4,Wn,'high') and then filter my signal with the b_fir coefficients nothing seems to happen.
I tried using fir1(48000, Wn,'high') and it seems to work but I don't think I'm using the right input parameter. The first input parameter is supposed to be a filter order, not the number of taps right?
Thanks for your response.
Honglei Chen
Honglei Chen el 20 de Mzo. de 2014
You are filtering 60 Hz out of 48 kHz, which is very narrow, so over 85% of band is untackled. I would not expect big change in signal. When you say it's not working, what do you exactly mean?
Sushma Chandran
Sushma Chandran el 25 de Mzo. de 2014
What I meant was that the signal appears unchanged when I export it out using the audiowrite command. There's absolutely no filtering occuring. How do I specify the correct number of taps for my FIR filter? The signal bandwidth is about 10 Hz to 16kHz (not 48kHz). I want to filter out everything 60 Hz and below.
Thanks for responding!
Honglei Chen
Honglei Chen el 26 de Mzo. de 2014
How strong is your signal below 60Hz and how are you comparing the signals? I wouldn't look at the time waveform for this. I would plot the spectrum as well as the filter's frequency response to make sure it is working as expected.
Sushma Chandran
Sushma Chandran el 31 de Mzo. de 2014
Since it's white noise the signal is about the same everywhere. I have attached a picture of what's happening. The first one is a picture of the white noise I am creating in audacity. The second one is after I apply my filter. For these pictures I ended up going with 50 Hz HPF. I think everything is working?

Iniciar sesión para comentar.

Más respuestas (0)

Etiquetas

Preguntada:

el 19 de Mzo. de 2014

Comentada:

el 24 de Ag. de 2014

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by