Use fdatool of MATLAB to generate the parameters of the IIR filter

Source: Internet
Author: User

Design of matlab iir Digital Filter

 

First, we need to understand related concepts.

How to correspond to the actual signal frequency when the angle frequency is used in digital filter design?

Angle frequencyW, Sampling frequencyFS,Actual Signal FrequencyFThe Conversion Relationship of is:

W = 2 * pI * f/FS

The angle frequency of sampling frequency is2 * pi.

The following uses a low-pass digital filter as an example. [See ]:

 

 

When the filter we designed is a band-pass. The cut-off frequency and the cut-off frequency are also two. The cutoff frequency is also called the edge frequency.

The FIR filter can be designed as a linear phase and always stable. In most cases, the Order nfir of the FIR filter is significantly greater than the order niir of the IIR filter with an equivalent amplitude response. Nfir/niir is generally 10 magnitude or higher. IIR filter is generally easier to calculate. In many applications, the filter is not required to have a strict linear phase. In these cases, the IIR filter is usually selected for ease of calculation. For example, many of the filters used in many Speech Encoding are IIR filters, and the equalizer generally use the IIR filter. That is to say, when the real-time requirement is not very high, you can consider using the FIR filter. When the order of the FIR filter is too long, you can consider using the FFT to calculate.

When designing an IIR filter, the design index of the digital filter is usually converted into the design index of the simulated low-pass prototype filter, so as to determine the transmission function of the analog low-pass filter that meets these indicators.Ha(S), And then convert it into the required digital filter transfer function.G(Z).

The above filter design process only needs to understand its principles. With the help of MATLAB powerful tools, the design of the filter has become relatively simple.

In the MATLAB command window, type fdatool and you will start the graphic interface of the filter design. You can directly select the digital filter control from the Simulink.

This article describes the design method of the IIR digital filter.

Filter the signal from the microphone.

Let us assume that we want to remove the 50Hz electrical frequency interference, and the frequency of human speech is generally not more than 3400Hz. We designed a band-pass filter with a passband of [80-3200] and a sampling rate of 8 K.

 

 

Based on the above requirements, we will change the relevant parameters to the following interface:

 

 

Click design filter, which is displayed as follows after several seconds:

 

It can be seen that the order of the filter is 36, and there is also a sections: 18. Because the implementation is generally achieved through cascade or parallel operation of level 2. So it is actually implemented in 18 level 2 sections.

Level 36 is the minimum level required by the system. You can also set the order in advance. The parameters are as follows:

 

At this time, the cut-off frequency attenuation parameter can no longer be selected, and is fixed to 3 decibels:

 

The final calculated range response is as follows:

We need to save the designed filter coefficients for other programs to call.

MATLAB provides a method for directly exporting coefficients.

 

[Targets]-> [generate C header]

 

You can modify it as follows and select generate]

 

 

 

In the MATLAB working directory, you can find the generated coefficient file, which is like the following:

 

 

This file is hard to understand. Return to the fdatool design page and select [analysis-> filter coeffcients ]:

 

 

 

The coefficient interface is consistent with the data in this file.

 

After carefully observing the data in the above interface, we found that the coefficient in the file actually divides it into two 2's section multiplication forms, and there is gain in it. The purpose of gain is to ensure the accuracy of calculation and system stability.

Choose Edit> convert to single section. At this time, the coefficient becomes a familiar form:

 

The generated coefficient C header file is as follows:

 

 

Specify the order 2. Repeat the above steps to generate the following file of the IIR filter coefficients:

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.