01-24-2014 01:49 AM - edited 01-24-2014 01:49 AM
Dear Sir/Madam,
I am trying to evaluate a simple convolution filter (LOWPASS), to produce the coefficients that will be used for FIR filtering signal on the ARM microcontroller.
I used two different softwares to design a proper filter:
1. Labview (Digital filter design)
2. Matlab (Signal processing toolbox)
I am confused, since the result coefficients are not the same (the attached image below). Both Matlab (100% sure) and Labview (not 100% sure) use nomalized frequency as the input for the design. The normalized frequency is:
fn = fcutoff / fsampling;
I tested this in Labview on some signal with different fcutoff and fsampling, BUT with the same normalized frequency and the result was always the same (so I assume that Labview uses the normalized frequency also).
The parameters of the filter:
fn = 0.2
type = lowpass
window = Hamming
filter order = 24
ntaps/coefficients = 25 (filter order + 1)
The result:
It looks like as though the filters are not of the same order - the main lobe width is smaller in the Labview example, and the side lobe height is larger. To my knowledge this suggest that the filter order is higher than one in the Matlab. But both filters produce the same number of coefficients...
Labview "code" (only numerator coefficients, since it is not a recursive filter):
and the corresponding Matlab code:
coeffML = fir1(24,0.2);
Does anybody know the reason for this? Or am I just making some silly mistake?
Thank you and best regards,
K
Solved! Go to Solution.
01-31-2014 09:41 AM
Hello Klemen,
I had a look at your problem and found short explanation. The difference is how do you understand normalized frequency and how Matlab does.
You can normalize frequency by fs or by nyquist frequency (fs/2 as Matlab does). Therefore your result for LV is different because you
expext normalization by fs.
Details can be found here:
http://www.mathworks.com/help/signal/ref/fir1.html
"Wn is a number between 0 and 1, where 1 corresponds to the Nyquist frequency"
http://en.wikipedia.org/wiki/Normalized_frequency_(digital_signal_processing)
"Some programs (such as MATLAB) that design filters with real-valued coefficients use the Nyquist frequency () as the normalization constant"
To solve your problem, whenever you want to compare Matlab results of FIR filters coefficients with LV you have to multiply fs in LV by 2 prior to normalization.
I also attached sample program with comparision where are default values computed according to recommendation above.
Have a nice weekend.
01-31-2014 06:12 PM
Hello,
thank you very much for your explanation and the attached example.
So to sum it up:
- Labview uses normalized frequency with valid values from 0 to < 0.5 (where 0.5 is fs/2)
- The analogy in Matlab is the normalized frequency from 0 to < 1 (where 1 is fs/2)
So for example 0.25 normalized in Labview is equal to 0.5 normalized in Matlab.
Should have been paying more attention to the documentation.
Thanks again and have a nice weekend.
K
02-02-2014 05:18 AM
Hello,
To explain: the problem is not in our documentation since VI FIR Windowed Coefficients does not use normalized frequency as Matlab does.
You, as the developer, have to create your own normalization in case of using this VI according to fs and cutoff frequency.
Therefore direct comparision of Matlab function fir1 and FIR Windowed Coefficients.vi is not relevant.
Regards,