Matlab filter design - design and simulation of IIR filter

Matlab filter design - design and simulation of IIR filter

1 Introduction
    In modern communication systems, because there are often various complex components mixed in the signal , many signal processing and analysis are based on filters. However, the design of traditional digital filters uses cumbersome formula calculations, and recalculation is required after changing parameters, so the workload is very heavy when designing filters, especially high-order filters. Using MATLAB signal processing box (Signal Processing Toolbox) can quickly and effectively realize the design and simulation of digital filter.

2. Digital filter and traditional design method
    Digital filter can be understood as a calculation program or algorithm , which converts the digital time series representing the input signal into the digital time series representing the output signal, and in the conversion process, makes the signal according to the predetermined Form changes. There are many classifications of digital filters. According to the time-domain characteristics of the digital filter impulse response, digital filters can be divided into two types, namely, infinite impulse response (IIR) filters and finite impulse response (FIR) filters. filter.
    The IIR digital filter has an infinitely wide impulse response, which matches the analog filter, so the design of the IIR filter can be further transformed on the basis of the analog filter design. The design methods mainly include classical design method, direct design method and maximum smoothing filter design method. The unit impulse response of the FIR digital filter is a sequence of finite length. Its design problem is essentially to determine the constant problem that can satisfy the required transfer sequence or impulse response. The design methods mainly include window function method, frequency sampling method and equiripple best approximation method.
    In the actual design of the filter, the calculation amount of the whole process is very large. When designing an IIR filter with a higher order, the amount of calculation is greater, and it must be recalculated when changing parameters or filter types during the design process.
    After the design is completed, the frequency response of the designed filter should be checked. To obtain the amplitude-frequency and phase-frequency response characteristics, the amount of calculation is also very large. Usually, the order and type of the digital filter to be designed are not necessarily completely given. In many cases, it is necessary to continuously adjust according to the design requirements and filtering effect to achieve the optimization of the design. In this case, filter design requires a large number of complex calculations, and it is difficult to complete it in a short period of time by simply calculating with formulas and compiling simple programs. Using the powerful calculation function of MATLAB for computer-aided design, digital filters can be designed quickly and effectively, which greatly simplifies the amount of calculation.

3 MATLAB design of IIR filter
3.1 FDATool interface design
3.1.1 FDATool introduction
    FDATool (Filter Design &Analysis Tool) is a dedicated filter design and analysis tool in the MATLAB signal processing toolbox. MATLAB 6.0 and above versions also specially add Filter Design Toolbox (Filter Design Toolbox). FDATool can design almost all conventional filters, including various design methods of FIR and IIR. It is easy to operate, convenient and flexible.
    FDA Tool. The interface is divided into two parts, one part is Design Filter. The lower part of the interface is used to set the design parameters of the filter; the other part is the characteristic area, which is used to display various characteristics of the filter in the upper part of the interface. The Design Filter part is mainly divided into: Filter Type (filter type) options, including Lowpass (low pass), Highpass ( high pass ), Bandpass (band pass), Bandstop (band stop) and special FIR filters.
   Design Method (design method) option, including Butterwotth (Butterworth) method of IIR filter, Chebyshev Type I (Chebyshev type I) method, Chebyshev Type II (Chebyshev type II) method, Ellipt ic ( elliptic filter Device) method and Equiripple method of FIR filter, Least-Squares (least square) method, Window (window function) method.
  Filter  OrThe der (filter order) option defines the order of the filter, including Specify Order (specified order) and Minimum Order (minimum order). Fill in the order of the filter to be designed in Specify Order (N order filter, Specify Order=N-1). If you select Minimum Order, MATLAB automatically uses the minimum order based on the selected filter type.
  The Frequency Specifications option can define the parameters of the frequency band in detail, including the sampling frequency and the cut-off frequency of the frequency band. Its specific options are determined by the Filter Type option and Design Method option. For example, a Bandpass (bandpass) filter needs to define Fstop1 (lower stopband cutoff frequency), Fpass1 (passband lower limit cutoff frequency), Fpass2 (passband upper limit cutoff frequency), Fstop2 (upper stopband cutoff frequency), and Lowpass (low pass) filter only need to define Fstop1, Fpass1. When using the window function to design the filter, since the transition band is determined by the type and order of the window function, it is only necessary to define the cut-off frequency of the passband instead of the stopband parameters.
    The Magnitude Specifications option can define the situation of amplitude attenuation. For example, when designing a bandpass filter, you can define Wstop1 (amplitude attenuation at frequency Fstop1), Wpass (amplitude attenuation within the passband range), and Wstop2 (amplitude attenuation at frequency Fstop2). When using the window function design, the amplitude attenuation at the cutoff frequency of the passband is fixed at 6db, so there is no need to define it.
  Window Specifications option, when the window function design is selected, this option can be defined, which includes various window functions.

3.1.2 IIR Filter Design Example
    This text takes the design of an IIR filter as an example to illustrate how to use MATLAB to design a digital filter. It is required to design a 10th-order bandpass Chebyshev I filter, its passband range is 100 to 200Hz, the sampling frequency is 1000Hz, Rp=0.5.
    In this example, first select Bandpass (bandpass filter) in Filter Type; select IIR in the Design Method option, and then select Chebyshev I (Chebyshev I type) in the adjacent right option; specify the Filter Order item Specify Order=10 in ; Since Chebyshev design is used, it is not necessary to select in Options ; then select Unit as Hz in Frequency Specifications, give sampling frequency Fs=1000, passband Fpass1=100 and Fpass2= 200; Finally, select Unit as db in Magnitude Specifications, Apass=0.5. After the setting is complete,
click Design Filter to get the designed IIR filter. Through the menu option Analysis, you can see the designed amplitude-frequency response, phase-frequency response, impulse response, and zero-pole configuration in the characteristic area, as shown in Figure 1. After the design is completed, save the result as filterl.fda file.

 

 
 

 
 

 
Fig. 1 Amplitude frequency, phase frequency and impulse response (characteristic area) of the filter

3.2 Programming method
  In MATLAB, there are corresponding functions for calculating amplitude, phase and impulse response for the design of various filters, which can be used for filter programming.
  The impulse response of the IIR filter in the above example can be programmed as follows:
%ehebyshevl bpf
n=10; % order is 10
Rp=0.5; % amplitude attenuation is 0.5
Wn[100 200]/500;
[b,a] =chebyl(n,Rp,wn);
[y,t]impz(b,a,101);
stem(t,y,'.');
    Run this program in the MATLAB environment to get the time domain of the filter impulse response. Due to limited space, the source program will not be described in detail here.

3.3 Design example analysis
   From Figure 1(a), we can see that this filter has equal ripples in the passband range of 100-200Hz, but is monotonic in the stopband, which is the amplitude-frequency characteristic of the Chebyshev I filter. It can be seen from Figure 1(b) that the phase shift is small in the range of 100-200Hz, and its curve is close to a straight line, and the distortion is small; when the frequency exceeds this range, the phase shift is large, and its curve is non-linear, So the distortion is also larger. Figure 1(c) shows the time-domain impulse response of the Chebyshev I filter. There is an impulse response in the range of 5ms-100ms, and the impulse response beyond this range is approximately zero, thereby realizing the design of the Chebyshev I bandpass filter
. .

Simulink simulation
4.1  Simulink simulation example
    By calling the function modules in Simulink, the simulation block diagram of the digital filter can be formed. During the simulation process, double-click each function module, change the parameters at any time, and obtain the simulation results under different states. For example, the original signal x(t)=2sin(0.05wt)+w(t), w(t) is a random signal with an amplitude of 0.2, through a transfer function H(z)=0.15/(1-0.8z- The filter of 1) can obtain the simulation result as shown in Fig. 2 . The filter file designed by FDATool can be imported during the simulation process.

 

 


 

 

4.2 Simulation analysis
    Comparing the waveforms of (b) and (c) in Figure 2, we can see that after the original input signal is filtered by the filter, the burr part (that is, the interference noise) of the waveform in (b) is filtered out, and the output signal is closer to A sine wave, as shown in (c). This shows that the design of the filter whose transfer function is H(z)=0.15/(1-0.8z-1) is appropriate.

5 Conclusion
    Using the powerful computing function of MATLAB, the digital filter design method based on the Signal Processing Toolbox of MATLAB can quickly and effectively design a conventional digital filter composed of software, the design is convenient and fast, and the work is greatly reduced. quantity. Filter characteristics can be compared during the design process. Change the parameters at any time to achieve the optimization of filter design. Using MATLAB to design digital filters has broad application prospects in digital communication systems and signal processing in the computer field, so it can be paid attention to.

[The above information is compiled and released by Aibo Testing. If there is any discrepancy, please correct it in time. If there is any quotation, please indicate the source. Welcome to discuss together. We have been paying attention to its development! Focus: CCC/SRRC/CTA/operator warehousing]

Guess you like

Origin blog.csdn.net/weixin_47371464/article/details/131766651