0
$\begingroup$

i'm trying to understand the fir1 filter but i still don't get it. For example here i got an audio signal that i consider noise, i'm passing it through a low pass filter.

n = 100000
fs = 11025
handles.noise = wavrecord(n, fs, 'double');
nfilt = fir1(11,0.4); 
fnoise = filter(nfilt,1,handles.noise); 

Why did i need to pass the noise signal to a low pass filter in the first place? and why is the number of coefficients 11? also the 0.4 shouldn't it be a range of values?

I know these are a lot of questions but when i get to understand them, ill be grateful to everyones help.

$\endgroup$
  • 1
    $\begingroup$ You ask "Why did i need to pass the noise signal to a low pass filter?" Nobody can answer that for you! You either have a reason to filter the signal, or you don't. If you are trying to ask something else, try rephrasing your question. $\endgroup$ – MBaz May 17 '15 at 20:52
  • $\begingroup$ This example was taken from a noise cancellation project using adaptive LMS filter. The noise signal is an input from a mic but was passed through a low pass filter. Why was it passed to a low pass filter instead of just using the filter function immediately? $\endgroup$ – Kyle May 17 '15 at 20:54
  • $\begingroup$ I think you're misunderstanding how to filter a signal in Matlab. It's a two step process: first design your filter (using fir1 or similar commands), then filter the signal with filter or conv. So, nfilt is a vector of filter coefficients, and fnoise is the filtered signal. In Matlab, just type doc fir1 to learn more. $\endgroup$ – MBaz May 17 '15 at 20:57
  • $\begingroup$ yes, but a question is when i design my filter. nfilt = fir1(11,0.4); why was 11 put in the number of coefficients? Why not 15? Does it depend on something? $\endgroup$ – Kyle May 17 '15 at 20:59
  • $\begingroup$ You should ask whoever wrote the program. In general, you want to use the smallest filter order that gives you the filter performance you need. Increasing the order also increases the number of calculations required to filter the signal. $\endgroup$ – MBaz May 17 '15 at 21:05
1
$\begingroup$

Matlab FIR-1 command designs FIR filters with at least two given parameters. P1: The order of the filter, P2: cutoff frequency, assuming a default lowpass filter. Order of the filter N determines a number of properties of the resulting filter such as its comptational complexity, transition bandwidth, passband and stop band ripples. In general large N gives better (closer to ideal) frequency response but worse computational load. Also order of filter being even or odd will have effect on zero-locations being at Nyquist frequency which might be important for some applications with high/low pass filters...

The second parameter, cutoff frequency, is basicaly determined by the application.

$\endgroup$
  • $\begingroup$ great! so the 0.4, what would happen if i increased/decreased it? $\endgroup$ – Kyle May 17 '15 at 21:20
  • $\begingroup$ 0.4 actually means passband between -0.4 and 0.4 radians for the, real impulse reponse, discrete time lowpass filter. Its value determined by your application. It could be 0.1 or may be 0.734 all based on what you should leave in the signal and out of the signal... $\endgroup$ – Fat32 May 17 '15 at 21:24
  • $\begingroup$ If you increase Wn, your filter accepts more frequency content of a higher frequency, rejecting less. $\endgroup$ – panthyon May 17 '15 at 21:29
0
$\begingroup$

The signal is lowpassed before LMS to make the adaptation portion easier, as it will be less likely to converge on a minima with high frequencies. The order 11 achieves particular rolloff. Increasing the order will create a steeper rolloff following the cutoff frequency. There is no issue with instability as FIRs do not have poles.

$\endgroup$
  • $\begingroup$ ok could you explain why 0.4 is used? Shouldn't it be something like fs/2 and then divided by 10 or something like that? and thank you for the above sentence! It really helped understanding. $\endgroup$ – Kyle May 17 '15 at 21:18
  • $\begingroup$ Typing 'help fir1' into matlab indicates fir1(N,Wn). Wn is the bandwidth. 0.4 is in the bandwidth in normalized frequency units. 1 is Fs/2 in normalized frequency units. $\endgroup$ – panthyon May 17 '15 at 21:21
  • $\begingroup$ also, if you find something helpful on this site, please upvote comments, answers, and questions too. (: $\endgroup$ – panthyon May 17 '15 at 21:22
  • $\begingroup$ oh i will, i'm registering now as a full user since i can't do anything while on a guest. $\endgroup$ – Kyle May 17 '15 at 21:31
  • $\begingroup$ 0.4 is in the bandwidth in normalized frequency units. 1 is Fs/2 in normalized frequency units <------- didn't get the second part. $\endgroup$ – Kyle May 17 '15 at 21:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.