Error using designfilt - parseAndDesignFilter: Coefficients must be finite
179 views (last 30 days)
Show older comments
MathWorks Support Team
on 31 Jul 2017
Answered: MathWorks Support Team
on 2 Aug 2017
Why does 'designfilt' throw an unexpected error while designing a FIR low-pass filter, specifically when the sample rate is high and difference between Passband and Stopband frequencies are very small?
Accepted Answer
MathWorks Support Team
on 31 Jul 2017
Consider the requirement to design a Low-Pass FIR filter with a Pass band frequency of 0.2 Hz, Stop band frequency of 0.3 Hz with a Sample rate of 1000 Hz. A filter can be designed using the 'designfilt' MATLAB function for the given specifications as shown in the below command:
>> lpFilt = designfilt('lowpassfir', 'PassbandFrequency', .2, 'StopbandFrequency', .3, 'SampleRate', 1000);
Upon executing the above command, 'designfilt' function throws an error: 'Error using designfilt>parseAndDesignFilter: Coefficients must be finite'. The input frequencies to the function by default are assumed to be 'Hz', and the filter design tool is unable to compute a FIR filter solution with a 0.20 Hz passband and 0.30 Hz stopband frequencies with sample rate set at 1000 Hz. The passband and stopband frequencies are very low, and the difference between them is very small to design a filter as the function uses a default Passband attenuation of 1 dB and a Stopband attenuation of 60 dB. To design a FIR filter with these constraints, consider parsing the 'FilterOrder' as one of the inputs. A very high order is necessary to design a FIR filter with these constraints as shown below:
>> lpFilt = designfilt('lowpassfir','FilterOrder', 100,'PassbandFrequency',.2, 'StopbandFrequency',.3, 'SampleRate', 1000);
>> fvtool(lpFilt)
If the provided passband and stopband frequencies are normalized, then 0.2 and 0.3 for a sample rate of 1000 Hz gets scaled to 200 Hz and 300 Hz respectively, and below is the suggested implementation. Specifying filter order is not necessary as the constraints with respect to sample rate are not tight, and MATLAB computes a filter of minimum order which meets the requirements:
>> lpFilt = designfilt('lowpassfir','PassbandFrequency',200, 'StopbandFrequency',300, 'SampleRate', 1000);
>> fvtool(lpFilt)
If the* objective is indeed to design a filter for 0.25 Hz and 0.35 Hz with a Sample Rate of 1000 Hz*, then a Low-Pass *IIR filter *can be designed instead due to the robustness properties of IIR filters. Below is the command to compute a low-pass IIR Filter, and to view the response:
>> lpFilt = designfilt('lowpassiir','PassbandFrequency',.2, 'StopbandFrequency',.3, 'SampleRate', 1000);
>> fvtool(lpFilt)
Please check the below provided documentation link for more information regarding the usage of the 'designfilt' function and input argument constraints for certain filter type implementations:
Alternatively, filters can be best designed and analyzed by visualizing them in a filter visualization tool. The Filter Designer GUI tool can also be accessed by typing the below command in the MATLAB Command Window:
>> filterDesigner
Please check the below provided documentation link for more information regarding the usage of the 'Filter design and analysis' tool:
0 Comments
More Answers (0)
See Also
Categories
Find more on Filter Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!