Method of Designing FIR Filter Using MATLAB

Publisher:浅唱清风Latest update time:2012-02-11 Keywords:MATLAB  fir Reading articles on mobile phones Scan QR code
Read articles on your mobile phone anytime, anywhere

Abstract This paper introduces three methods of FIR filter design using MATLAB signal processing toolbox: program design method, FDATool design method and SPTool design method. Detailed design steps are given, and the designed filter is applied to a mixed sine wave signal to verify the performance of the filter.
Keywords MATLAB, digital filter, finite impulse response, window function, simulation

1 Introduction
A digital filter is a digital system used to filter discrete-time signals. It achieves the purpose of frequency domain filtering by mathematically processing the sampled data. According to the time domain characteristics of its unit impulse response function, it can be divided into two categories: infinite impulse response (IIR) filter and finite impulse response (FIR) filter. Compared with IIR filters, the implementation of FIR is non-recursive and always stable; more importantly, FIR filters can obtain strict linear phase characteristics while meeting the amplitude-frequency response requirements. Therefore, it is widely used in high-fidelity signal processing, such as digital audio, image processing, data transmission, biomedicine and other fields.

2 Window Function Design Method of FIR Filter
There are many methods for designing FIR filters, such as window function design method, frequency sampling design method and optimization design method. The basic principle of window function design method is to use a certain width window function to intercept an infinite impulse response sequence to obtain a finite length impulse response sequence. The main design steps are:
(1) Obtain the unit impulse response hd(n) of the ideal filter through inverse Fourier transform.



(2) Determine the window function W(n) and window length N based on the performance index.
(3) Obtain the unit impulse response h(n) of the actual filter, h(n) is the designed FIR filter coefficient vector b(n). (4) Test the filter performance. This paper will design a FIR bandpass filter for a mixed sine wave signal containing 5Hz, 15Hz and 30Hz, and give three methods to implement it using MATLAB: program design method, FDATool design method and SPTool design method. Parameter requirements: sampling frequency fs=100Hz, passband lower limit cutoff frequency fc1=10 Hz, passband upper limit cutoff frequency fc2=20 Hz, transition bandwidth 6 Hz, pass-stop band fluctuation 0.01, and Kaiser window design.


2 Programming method
MATLAB signal processing toolbox provides a variety of window functions, filter design functions and filter implementation functions. The bandpass filter design and filtering program of this article are as follows:
[n,Wn,beta,ftype]=kaiserord([7 13 17 23],[0 1 0],[0.01 0.01 0.01],100);
%The order of the filter is n=38, beta=3.4
w1=2*fc1/fs; w2=2*fc2/fs; %Convert the technical indicators of the analog filter to the technical indicators of the digital filter
window=kaiser(n+1,beta); %Use the kaiser window function
b=fir1(n,[w1 w2],window); Use the standard frequency response window design function fir1
freqz(b,1,512); %Digital filter frequency response
t = (0:100)/Fs;
s = sin(2*pi*t*5)+sin(2*pi*t*15)+sin(2*pi*t*30);%Mixed sine wave signal
sf = filter(b,1,s);%Filter signal s
The result of program execution is shown in Figure 1:



(1) Filter amplitude-frequency characteristics and phase-frequency characteristics (2) Waveforms before and after filtering
Figure 1 Filter characteristics and filtering effect diagram


4 FDATool design method
FDATool (Filter Design & Analysis Tool) is a filter design and analysis tool dedicated to the MATLAB signal processing toolbox. It is simple and flexible to operate, and can use a variety of methods to design FIR and IIR filters. Enter FDATool in the MATLAB command window and press Enter to pop up the FDATool interface.
4.1 Bandpass filter design
The order of the known filter is n=38, beta=3.4. In this example, first select Bandpass in Filter Type; select FIR Window in the Design Method option, then select Kaiser in the Window option, and the Beta value is 3.4; specify the Specify order in the Filter Order item to 38; sampling frequency Fs=100Hz, cutoff frequency Fc1=10Hz, Fc2=20Hz. After setting, click Design Filter at the bottom of the window, and you will see the amplitude-frequency response of the designed filter at the top of the window. Through the menu option Analysis, you can also see the phase-frequency response, group delay, impulse response, step response, zero-pole configuration, etc. of the filter. After the design is completed, save the result as kaiser15.fda file.
4.2 Simulink simulation
In the Simulink environment, the filter file kaiser15.fda is imported into the Digital Filter Design module. The input signal is s(t)=sin(10πt)+sin(30πt)+sin(60πt). The generated simulation diagram and filtering effect are shown in Figure 2.



(1) Simulink simulation diagram (2) Discrete waveforms before and after filtering
Figure 2 Simulink simulation diagram and filtering effect diagram

5 SPTool design method
SPTool is an interactive graphical user interface tool that comes with the MATLAB signal processing toolbox. It includes most of the functions in the signal processing toolbox and can easily and quickly complete the analysis, design and browsing of signals, filters and spectra. In this example, the following steps are taken to complete the design and filtering of the filter:
Create and import the signal source.
Enter the command in the MATLAB command window:
Fs = 100; t = (0:100)/Fs;
s = sin(2*pi*t*5)+sin(2*pi*t*15)+sin(2*pi*t*30);
At this time, the variables Fs, t, and s will be displayed in the workspace list. Type Sptool in the command window, and the Sptool main interface will pop up, as shown in Figure 3; click the menu File/Import to import the signal s and name it s.
(2) Click New under the Filters list and design the filter filt1 according to the parameter requirements. The specific steps are similar to 3.2.1.
(3) Apply the filter filt1 to the s signal sequence. Select s, filt1, and mtlbse in the Signals, Filters, and Spectra lists respectively, click the Apply button under the Filters list, and name the output signal sin15hz in the Apply Filter dialog box that pops up.
(4) Perform spectrum analysis. Select s in Signals, click the Create button under Spectra, select Method as FFT and Nfft=512 in the Spectra Viewer interface that pops up, and click the Apply button to generate the spectrum spect1 of s. The same steps can be used to generate the spectrum spect2 of the signal sin15hz.
Select the signals s, sin15hz, spect1, and spect2 respectively, and click the View button under each list to observe their waveforms, as shown in Figure 4.



Figure 3 SPTool main interface Figure 4 Time domain waveform and frequency domain characteristics before and after filtering
As can be seen from Figure 4, the bandpass filter filt1 allows the 15 Hz sine wave signal in the input signal s to pass, while greatly attenuating the 5 Hz and 30 Hz sine wave signals.

6 Conclusion
This paper introduces three methods of using MATLAB to implement FIR filter design and filtering through a design example. From the simulation results, it can be seen that they can all meet the technical index requirements, and the methods are simple and fast, which greatly reduces the workload. After the filter design work is completed, the system function H(z) of the designed filter can be exported with the help of MATLAB's export operation. Since MATLAB has powerful interface functions, the simulation results can be easily transplanted to devices such as DSP, CPLD or FPGA. In practical applications, only the filter parameters need to be modified as required, and the program needs to be modified slightly to realize FIR filters with different cutoff frequencies, which is very practical.

Keywords:MATLAB  fir Reference address:Method of Designing FIR Filter Using MATLAB

Previous article:DES algorithm principle
Next article:IIR filter source program designed using matlab - IIR first-order low-pass/high-pass

Recommended ReadingLatest update time:2024-11-16 20:55

Communication between Matlab and digital oscilloscope
    Abstract: The communication process between Matlab and TDS series digital oscilloscopes under Windows environment is given. The relevant communication procedures are given, and the waveform data read by the oscilloscope is processed in the frequency domain in Matlab. This shows that the communication between them
[Industrial Control]
Application of LabVIEW and MATLAB Hybrid Programming in Digital Antenna Array Testing
introduction Digital antenna array is the product of the combination of antenna and digital signal processing technology. It has many advantages such as flexible working mode, excellent anti-interference performance and super angular resolution. Therefore, it has been widely used in military and civilian fiel
[Test Measurement]
Application of LabVIEW and MATLAB Hybrid Programming in Digital Antenna Array Testing
Design of serial multi-order FIR filter based on FPGA+MATLAB
Digital filter is a digital system used to filter discrete time signals. It achieves the purpose of frequency domain filtering by mathematically processing the sampled data. According to the time domain characteristics of the unit impulse response function, it can be divided into two categories: infinite impulse respo
[Embedded]
Design of serial multi-order FIR filter based on FPGA+MATLAB
Harmonic Analysis and Simulation of Dead Zone Effect of AC/DC/AC Power Supply Based on MATLAB
0Introduction At present, most of the control methods of various inverter power supplies and the analysis of SPWM signal modulation methods are based on the assumption that the power switch device is an ideal switch device, that is, the rise, fall and storage time of the switch device are not considered. But in fact
[Power Management]
Design of analog bandpass filter based on Matlab GUI
0 Introduction Analog bandpass filters play an important role in the detection and transmission of signals, but the design process of traditional analog bandpass filters requires a lot of tedious numerical calculations, which is time-consuming and laborious if calculated manually. Many companies have also d
[Analog Electronics]
Teach you how to design a signal generator GUI interface based on MATLAB in one hour (2)
3.xx.m file design After placing the above components in xx.fig, there will be some codes in xx.fig. Ignore it and right-click on the button of xx.fig → click callback → callback! You can see the corresponding .m code in the xx.m file This is the callback code under the AM button. function pushbutton1_Callback(hObje
[Test Measurement]
Teach you how to design a signal generator GUI interface based on MATLAB in one hour (2)
Design of Type I FIR Digital Filter Based on Simulated Annealing Neural Network
0 Introduction IIR filters are not easy to make into linear phase, but FIR filters can be made into linear phase as long as certain conditions are met. The requirement for linear phase is universal in modern image, voice and data communications, so FIR digital filters with linear phase have been widely deve
[Analog Electronics]
Latest Embedded Articles
Change More Related Popular Components

EEWorld
subscription
account

EEWorld
service
account

Automotive
development
circle

About Us Customer Service Contact Information Datasheet Sitemap LatestNews


Room 1530, 15th Floor, Building B, No.18 Zhongguancun Street, Haidian District, Beijing, Postal Code: 100190 China Telephone: 008610 8235 0740

Copyright © 2005-2024 EEWORLD.com.cn, Inc. All rights reserved 京ICP证060456号 京ICP备10001474号-1 电信业务审批[2006]字第258号函 京公网安备 11010802033920号