Digital Signal Processing Experiment (v) Design of--IIR filter

Source: Internet
Author: User

I. Using the self-coding function to design IIR filter 1, impulse response method

(1) The digital filter indicator given in the note is first modeled as a simulation indicator

(2) Design the analog filter:

(3) Convert to digital filter using impulse response method

(4) a demo

Clear All;wp=0.2*pi; %Digital Indicator WS=0.3*Pi; Rp=1; as= the; T=1; fs=1/T;%Impulse response method [Cs,ds]=afd_butt (wp/t,ws/t,rp,as); [B,a]=IMP_INVR (cs,ds,t); [C,b,a]=Dir2par (B,a) [Db,mag,pha,grd,w]=freqz_m (b,a); figure (1) Subplot (2,2,1), Plot (W/pi,mag), title ('amplitude'); Grid;axis ([0,1,0,1.1]); subplot (2,2,2), Plot (w/pi,db), title ('amplitude in db'); Grid;axis ([0,1,- -,5]); subplot (2,2,3), Plot (W/PI,PHA/PI), title ('Phase'); Grid;axis ([0,1,-1,1]); subplot (2,2,4), Plot (W/PI,GRD), title ('Group Delay'); Grid;axis ([0,1,0,Ten]);

2. Design IIR with bilinear method

(1) Pre-distortion:

(2) Design of low-pass filter

(3) Convert to digital filter

(4) a demo

%= (2/t) *tan (wp/2= (2/t) *tan (ws/2);             %= Afd_butt (omegap,omegas,rp,as); %== Dir2cas (b,a) [db,mag,pha,grd,w]=freqz_m (b,a);

Second, Matlab self-function design 1, analog low-pass filter to digital filter design

(1) Design the order n and cutoff frequency of the analog filter according to the digital index

(2) to find a low-pass analog prototype filter

(3) As the resulting result is a 0-pole type, it must also be converted to b/a type, usable function ZP2TF

[Bap,aap]=zp2tf (Z,p,k)

(4) Convert analog filter to digital filter

(Low-pass, high-pass, band-pass, Band-stop) available functions LP2LP, Lp2hp,lp2bs, lp2bp.

(5) Calculating the amplitude frequency, phase frequency and impulse response of the filter

(6) a demo

wp=0.2*pi; rp=1; Ws=0.3*pi; as= the; [N,wn]=buttord (Wp,ws,rp,as,'s') [Z,p,k]=Buttap (n); [Bap,aap]=ZP2TF (z,p,k) [B,a]=LP2LP (BAP,AAP,WN); [Db,mag,pha,w]=freqs_m (B,a,0.5*pi); [Ha,x,t]=Impulse (b,a); figure (1) Subplot (2,2,1), Plot (W/pi,mag), title ('amplitude'); Subplot (2,2,2), Plot (w/pi,db), title ('amplitude in db'); subplot (2,2,3), Plot (W/PI,PHA/PI), title ('Phase'); Subplot (2,2,4), Plot (T,ha), title ('Impulse Response'); figure (2) Freqs (b,a);

2, direct digital filter design

(1) According to the given indicators, the low-pass analog prototype filter order and cutoff frequency:

[N,wn]=Buttord (Wp,ws,rp,as) [N,wn]=cheb1ord (wp,ws,rp,as)

(2) The digital filter is obtained directly, and the function butter,cheby1,cheby2 is used.

[b,a]=butter (n,wn, ' ftype ') [B,a]=cheby1 (n, rp,wn, ' ftype ')  ; ' ftype ' means: ' low ', ' bandpass ', ' High ', ' Stop

(3) Calculating the amplitude frequency, phase frequency and group delay of the filter

[Db,mag,pha,grd,w]=freqz_m (b,a);(P 258) directly draw the amplitude and phase frequency characteristics: FREQZ (b,a) (Matlab comes with)

(4) a demo

wp=0.2; rp=1; ws=0.3; as= the; [N,wn]=Buttord (Wp,ws,rp,as) [B,a]=butter (N,WN); [Db,mag,pha,grd,w]=freqz_m (b,a); figure (3) Subplot (2,2,1), Plot (W/pi,mag), title ('amplitude'); grid; Subplot (2,2,2), Plot (w/pi,db), title ('amplitude in db'); grid; Subplot (2,2,3), Plot (W/PI,PHA/PI), title ('Phase'); Grid;subplot (2,2,4), Plot (W/PI,GRD), title ('Group Delay'); Grid;figure (4); Freqz (B,a)
Ps:

MATLAB, the digital angular frequency is normalized, that is, 0-1 means 0-pi

Frequency is given in Hz, which means analog frequency, so the direct design of the filter using MATLAB, the first to be converted into a digital frequency.

Example: wp=[100 200]*2/fs

Digital Signal Processing Experiment (v) Design of--IIR filter

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.