TECHNOLOGICAL INSTITUTE OF THE PHILIPPINES
938 AURORA BOULEVARD, CUBAO, QUEZON CITY
Advanced Digital Signal Processing
Chapter 6: Digital Signal Processing Systems,
Basic Filtering Types, and Digital Filter
Realizations
MATLAB Problems
Rating
Bacani, Gabriel A.
EC42FB1
Engr. Francis Malit
Instructor
January 11, 2016
MATLAB Problems
6.19. Given a filter
H ( z )=
1+2 z1+ z 2
1
2
10.5 z +0.25 z
a. use MATLAB to plot
1. its magnitude frequency response;
2. its phase response.
SOLUTION:
a)
[h w] = freqz([1 2 1],[1 -0.50 0.25],1024);
phi = 180*unwrap(angle(h))/pi;
subplot(2,1,1), plot(w,abs(h)),grid;xlabel('Frequency (radians)'),
ylabel ('Magnitude')
subplot(2,1,2), plot(w,phi),grid;xlabel('Frequency (radians)'),
ylabel('Phase (degrees)')
6.20. Given the difference equation
a. use the MATLAB functions filter() and filtic() to calculate the system response y(n) for n = 0, 1, 2, 3, . . . , 4
n
with the input of x(n) = (0:5) u(n) and initial conditions: x( - 1) = -1, y( - 2) = 2, and y( - 1) = 1;.
b. use the MATLAB function filter () to calculate the system response y(n) for n = 0, 1, 2, 3, . . . . 4 with the
input of x(n) = (0.5)nu(n) and zero initial conditions : x(-1) = 0, y(-2) = 0 and y(-1) = 0.
Solution:
y ( n )=b o x ( n ) +b 1 x ( n1 ) ++b M x ( nM )a 1 y ( n1 ) a N y (nN )
a)
B=[ b o b 1 b 2 ] =[0 1]
A= [ a0 a1 a2 ]=[1 0.75 0.125]
x=[1 0.5 0.25 0.125 0.0625]
X i= [ x (1 ) x (2 ) ]=[ 10 ]
Y i=[ y (1 ) y (2 ) ]=[12]
Z i=filtic ( B , A ,Y i , X i )
y=filter (B , A , x , Z i)
b)
B=[ b o b 1 b 2 ] =[0 1]
A= [ a0 a1 a2 ]=[1 0.75 0.125]
x=[1 0.5 0.25 0.125 0.0625]
y=filter (B , A , x)
6.21. Given a filter
a.
b.
c.
d.
plot the magnitude frequency response and phase response using MATLAB;
specify the type of filtering;
find the difference equation;
perform filtering, that is, calculate y(n) for the first 1,000 samples for each of
the following inputs and plot the filter outputs using MATLAB, assuming that
all initial conditions are zeros and the sampling rate is 8,000 Hz:
e. repeat (d) using the MATLAB function filter().
SOLUTION:
a)
[h w] = freqz([1 -1 1],[1 -0.90 0.81],1024)
phi = 180*unwrap(angle(h))/pi;
subplot(2,1,1), plot(w,abs(h)),grid;xlabel('Frequency (radians)'),
ylabel ('Magnitude')
subplot(2,1,2), plot(w,phi),grid;xlabel('Frequency (radians)'),
ylabel('Phase (degrees)')
b) Bandstop filter
c)
H ( z )=
Y (z)
1z1 + z2
=
X ( z) 10.9 z1 +0.81 z2
Y ( z ) [ 10.9 z1+ 0.81 z2 ]=X ( z ) [1z1+ z 2 ]
Y ( z ) 0.9 z 1 Y ( z ) +0.81 z2 Y ( z ) =X ( z )z1 X ( z )+ z2 X (z )
Applying inverse Z-transform,
y ( n )0.9 y ( n1 ) +0.81 y ( n2 )=x ( n )x ( n1 ) + x (n2)
y ( n )=x ( n )x ( n1 ) +0.9 y ( n1 )0.81 y (n2)
d)
1)
2)
3)
e)
y 1=[column 1 column 2column 3 column 998 column 999 column 1000]
1)
y 1=1.0000 0.8239 0.7147 0.32180.69700.9661
2)
y 2=1.0000 0.40000.4500 0.0000 0.0000 0.0000
3)
y 3=1.00000.80710.1707 0.82820.06800.7321