Professional Documents
Culture Documents
Chapter 1
x(n) = A cos(0 n)
M 1.1 Write a MATLAB program to generate a sinusoidal sequence and plot
the sequence using the stem function. The input data specified by the user are the desired length
L , amplitude A , and the angular frequency 0 , where 0 < 0 < . Using this program,
generate the sinusoidal sequences shown in Fig. 1.1.
Solution:
clc; clear all; close all;
L=input('Desired length= ');
A=input('Amplitude= ');
omega=input('Angular frequency= ');
n=0:L-1;
x=A*cos(omega*n);
stem(n,x);
xlabel('n');ylabel('amplitude');
title([' \ omega_0= ',num2str(omega)]);
0 = 0, / 8, / 2,
The result for various frequencies ( ) is shown below:
M 1.2 Generate and plot each of the following sequences over the indicated interval.
10
x1 (n) = (m 1)[ (n 2m) (n 2m 1)]
(a) m =0 , 0 n 25 .
x2 (n) = 2 (n 2) (n) (n 4) 5 n 5
(b) , .
Results of M 1.2:
M 1.3 Generate and plot x ( n) = cos(0.3 n) , 20 n 20 . Is this sequence periodic? If it is,
what is its fundamental period? From the examination of the plot, what interpretation can you
k
fd =
give to the integers k and N where N .
Solution: The frequency of the given signal x ( n) = cos(0.3 n) is given by
= 0.3
0.3 3 k
fd = = = =
2 2 20 N
Results of M 1.3:
M 1.4 Consider a discrete-time system with input x(n) and output y (n) related by
n 10
y ( n) = x( k )
k = n 10
x ( n)
Let 1 be a Gaussian random sequence with mean 0 and variance 10 over 0 n 100 .
Using this sequence, test the time invariance of this system. Choose any values for sample shift
n0
in Eq. (1.81). You should use several realizations of this sequence to arrive at your answer.
Solution:
clc; clear all; close all;
%** input x1(n) **
x1=sqrt(10)*randn(1,100);
x11=[zeros(1,10) x1 zeros(1,10)];
%**input x2(n)=x1(n-n0) **
n0=5; % shifting constant
x2=[zeros(1,n0) x1]; % x1(n) shifted by 5
x22=[zeros(1,n0) x11];
%** y1(n) from x1(n) **
for n=1:100
sum1=0;
The result is shown below. Note that whenever we run this program, we get different
plots because this program involves randn commands. Since for each realization
y2 (n) = y1 (n n0 )
, system is time invariant.
Or
The signals
are both sampled with f s = 10 Hz. Show that the two sequences of samples so obtained are
identical.
x1 (t ) |t = nT = x1 (nTs ) = x1 (n)
s
= cos(26 nTs )
13
= cos 2 n
10
3
= cos 2 n 2 n
10
3
= cos 2 n
10
x2 (t ) |t = nT = x2 (nTs ) = x2 (n)
s
= cos(6 nTs )
3
= cos 2 n = x1 (n)
10
t=0:0.0005:1;
f=13;fs=10;
xt=cos(2*pi*f*t);
Ts=0.1;
n=0:Ts:1;
xn=cos(2*pi*f*n);
k=0:length(n)-1;
N=length(xn);
Nt=length(t);
xr=zeros(1,Nt);
xp=zeros(1,Nt);
for k=1:N
xr=xr+xn(k)*sinc((t-(k-1)*Ts)/Ts);
end
plot(t,xt);hold on
stem(n,xn,'filled');
hold on;
plot(t,xr);
ylabel('Amplitude');
M 3.1 Write a MTALAB program to compute the convolution of the following two sequences:
x( n) = {2,1, 3, 2,1, 3, 2,1, 3,} , and h( n) = {1,1} . Here x(n) is a periodic sequence.
x=[2,1,-3,2,1,-3,2,1,-3,2,1];
h=[1,1];
nx=[0:10];LEx=nx(1);
nh=[0:1];LEh=nh(1);
Nx=length(x);
Nh=length(h);
LEy=LEx+LEh;
REx=nx(Nx);
REh=nh(Nh);
REy=REx+REh;
Ny=Nx+Nh-1;
Xn=[x zeros(1,Ny-Nx)];
Hn=[h zeros(1,Ny-Nh)];
for i=0:Ny-1
sum=0;
for j=0:i
sum=sum+Xn(j+1)*Hn(i-j+1);
end
Y(i+1)=sum;
end
subplot(131);
xlabel('n');
title('x(n)');
subplot(132);
stem(nh,h,'filled');
xlabel('n');
title('h(n)');
subplot(133);
ny=LEy:REy;
stem(ny,Y, 'filled');
xlabel('n');
title('y(n)');
Thus,
The response y (n) is periodic with period N = 3 , except for start-up effects (which last for one
period). One period of the convolution is y ( n) = {1, 3, 2} . The result is shown in Fig. 3.1.
sampled signal transmitted towards target and y (n) be the received signal.
y (n) = 0.8 x( n 2) w( n)
where w( n) is Gaussian noise sequence with mean 0 and variance 1 . Compute the cross-
correlation between y (n) and x(n) . Use the plot to estimate the value of the delay D .
Solution: From the construction of y (n) , it follows that y (n) is similar to x ( n 2) and hence
their cross-correlation would show the strongest similarity at m = 2 .
%***input signal*******
x=[3 11 7 0 -1 4 2];
nx=-3:3;
%**shifted signal**
xs=x;ny=nx+2;
%**y(n)=x(n-2)+w(n)****
w=randn(1,length(ny));
nw=ny;y=xs+w;
yf=fliplr(y);
%*************
Ryx=conv(x,yf);
N1=length(nx);
N2=length(ny);
n3=(nx(1)+ny(1)):(nx(N1)+ny(N2));
stem(n3,Ryx,'filled');
From Fig. 3.2, we observe that the cross-correlation indeed peaks at m = 2 , which implies that
M 4.1. Let x1 (n) be periodic with fundamental period N = 50 , where one period is given by
ne 0.3n 0 n 25
x1 ( n) =
0 26 n 49
and let x2 (n) be periodic with fundamental period N = 100 , where one period is given by
ne 0.3 n 0 n 25
x2 ( n) =
0 26 n 99
These two periodic sequences differ in their periodicity but otherwise have equal non-zero
samples.
(a) Find the DTFS X k of x1 (n) and plot samples of its magnitude and phase versus k .
(b) Find the DTFS X k of x2 (n) and plot samples of its magnitude and phase versus k .
(c) What is the difference between the two DTFS plots of (a) and (b)?
N=50;n=0:N-1;
k=0:N-1;
n1=0:25;
xn=[n1.*exp(-0.3*n1) zeros(1,24)];
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN. (nk);
Xk=(xn*WNnk)/N;
magXk=abs([Xk(N/2+2:N) Xk(1:N/2+1)]);
phaseXk=angle([Xk(N/2+2:N) Xk(1:N/2+1)]);
k1=[-N/2+1:N/2];
stem(k1,magXk,'filled');
xlabel('k');ylabel('|Xk|');
title('Magnitude');
subplot(122);
stem(k1,phaseXk,'filled');
xlabel('k');ylabel('angleXk');
title('Phase');
N=100;n=0:N-1;
k=0:N-1;
n1=0:25;
xn=[n1.*exp(-0.3*n1) zeros(1,74)];
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN. (nk);
Xk=(xn*WNnk)/N;
magXk=abs([Xk(N/2+2:N) Xk(1:N/2+1)]);
phaseXk=angle([Xk(N/2+2:N) Xk(1:N/2+1)]);
k1=[-N/2+1:N/2];
subplot(121);
stem(k1,magXk,'filled');
xlabel('k');ylabel('|Xk|');
subplot(122);
stem(k1,phaseXk,'filled');
xlabel('k');ylabel('angleXk');
title('Phase');
(c) The envelope of both figures is same, but Fig. 4.1 (b) is highly dense
X k = {5, 2 j ,3,2 j}
N=4;n=0:N-1;
k=0:N-1;
WN=exp(-j*2*pi/N);
nk=n'*k;
WNnk=WN. (-nk);
xn=Xk*WNnk;
magxn=abs([xn(N/2+2:N) xn(1:N/2+1)]);
phasexn=angle([xn(N/2+2:N) xn(1:N/2+1)]);
magxn
phasexn
phasexn =
M 5.1. Let x( n) = {1, 2,3, 4,5, 6, 7,8,9} . Let y ( n) = x ( n 5) . Verify the time-shifting property of
the DTFT.
Solution:
clc; clear all; close all;
num1=[1 2 3 4 5 6 7 8 9];
den=[1];
D=5;%Delay
w=‐pi:0.01:pi;
Xw=freqz(num1,den,w);
num2=[zeros(1,D) num1];
Yw=freqz(num2,den,w);
subplot(221);
plot(w/pi,abs(Xw));
title('Magnitude spectrum of original sequence');
subplot(222);
plot(w/pi,angle(Xw));
title('Phase spectrum of original sequence');
subplot(223);
plot(w/pi,abs(Yw));
title('Magnitude spectrum of shifted sequence');
subplot(224);
title('Phase spectrum of shifted sequence');
Solution:
clc; clear all; close all;
n=0:100;
w=‐pi:0.01*pi:pi;
x=cos(n*pi/2);
Xw=x*exp(‐j*n'*w);
y=exp(j*n*pi/4).*x;
Yw=y*exp(‐j*n'*w);
subplot(221);
title('Magnitude spectrum of X');
subplot(222);
plot(w/pi,angle(Xw));
title('Phase spectrum of X');
subplot(223);
plot(w/pi,abs(Yw));
title('Magnitude spectrum of Y');
subplot(224);
plot(w/pi,angle(Yw));
title('Phase spectrum of Y');
The resulting plot is shown in Fig. 5.2. From plots in Fig. 5.2, we observe that X (e j ) is
indeed shifted by in both magnitude and phase.
4
M 5.3. Let x1 ( n) = {1,1,1} and x2 ( n) = {1,1,1} . Verify the convolution property of the DTFT.
clc; clear all; close all;
w=‐pi:0.01:pi;
x1=[1 1 1];
x2=[1 1 1];
y=conv(x1,x2);
X1w=freqz(x1,1,w);
X2w=freqz(x2,1,w);
X3w=X1w.*X2w;
Yw=freqz(y,1,w);
subplot(221);
plot(w/pi,abs(X3w));
subplot(222);
plot(w/pi,angle(X3w));
title('Sum of Phase spectra');
subplot(223);
plot(w/pi,abs(Yw));
title('Magnitude spectrum of convolved sequence');
subplot(224);
plot(w/pi,angle(Yw));
title('Phase spectrum of convolved sequence');
M 5.4. Let x( n) = {1, 2,3, 4,5, 6, 7,8,9} and y ( n) = x ( n) . Verify the time-reversal (folding)
clc; clear all; close all;
num1=[1 2 3 4 5 6 7 8 9];
den=[1];
L=length(num1)‐1;
w=‐pi:0.01:pi;
Xw=freqz(num1,den,w);
num2=fliplr(num1);
Y=freqz(num2,den,w);
Yw=exp(j*L*w).*Y;
subplot(221);
plot(w/pi,abs(Xw));
title('Magnitude spectrum of original sequence');
subplot(222);
plot(w/pi,angle(Xw));
title('Phase spectrum o original sequence');
subplot(223);
plot(w/pi,abs(Yw));
title('Magnitude spectrum of time‐reversed sequence');
subplot(224);
plot(w/pi,angle(Yw));
Solution:
clc; clear all; close all;
w=‐pi:0.01:pi;
n=0:100;
xn=(0.9).n;
Xw=xn*exp(‐j*n'*w);
MagX=abs(Xw);
PhaseX=angle(Xw);
subplot(121);
ylabel('Magnitude');
subplot(122);
plot(w/pi,PhaseX);
ylabel('Phase');
1
y (n) = [ x(n) x(n 1)]
2
Find H ( z) and sketch its pole-zero plot. Plot the magnitude response | H (e j ) | and phase
response H (e j ) .
Solution:
Y ( z) 1
= H ( z ) = [1 z 1 ]
X ( z) 2
1
H (e j ) = [1 e j ]
2
w=0:0.01:pi;
b=[0.5 0.5];a=[1];
subplot(311);zplane(b,a)
Hw=(1/2)*(1+exp(-j*w));
subplot(312);plot(w/pi,abs(Hw)); xlabel('frequency in pi
units);
ylabel('magnitude')
subplot(313);
plot(w/pi,angle(Hw)*180/pi);
xlabel('frequency in pi units');
ylabel('phase (degrees)')
w=0:0.01:pi;
b=[0.5 0.5];a=[1];
subplot(311);zplane(b,a)
Hw=freqz(b,a,w);
subplot(312);plot(w/pi,abs(Hw)); xlabel('frequency in pi
units);
ylabel('magnitude')
subplot(313);
plot(w/pi,angle(Hw)*180/pi);
xlabel('frequency in pi units');
ylabel('phase (degrees)')
1.
1
y (n) = [ x(n) x(n 1)]
2
Find H ( z) and sketch its pole-zero plot. Plot the magnitude response | H (e j ) | and phase
response H (e j ) .
Solution:
Y ( z) 1
= H ( z ) = [1 z 1 ]
X ( z) 2
1
H (e j ) = [1 e j ]
2
w=0:0.01:pi;
b=[0.5 -0.5];a=[1];
subplot(311);zplane(b,a)
Hw=(1/2)*(1-exp(-j*w));
subplot(312);plot(w/pi,abs(Hw)); xlabel('frequency in pi
units);
ylabel('magnitude')
subplot(313);
plot(w/pi,angle(Hw)*180/pi);
xlabel('frequency in pi units');
ylabel('phase (degrees)')
1
y (n) = [ x(n) x(n 2)]
2
Find H ( z) and sketch its pole-zero plot. Plot the magnitude response | H (e j ) | and phase
response H (e j ) .
Solution:
Y ( z) 1
= H ( z ) = [1 z 2 ]
X ( z) 2
1
H (e j ) = [1 e j 2 ]
2
w=0:0.01:pi;
subplot(311);zplane(b,a)
Hw=(1/2)*(1-exp(-j*2*w));
subplot(312);plot(w/pi,abs(Hw)); xlabel('frequency in pi
units);
ylabel('magnitude')
subplot(313);
plot(w/pi,angle(Hw)*180/pi);
xlabel('frequency in pi units');
ylabel('phase (degrees)')
1
y (n) = [ x(n) x(n 2)]
2
Find H ( z) and sketch its pole-zero plot. Plot the magnitude response | H (e j ) | and phase
response H (e j ) .
Solution:
Y ( z) 1
= H ( z ) = [1 z 2 ]
X ( z) 2
1
H (e j ) = [1 e j 2 ]
2
w=0:0.01:pi;
b=[0.5 0 0.5];a=[1];
subplot(311);zplane(b,a)
Hw=(1/2)*(1+exp(-j*2*w));
subplot(312);plot(w/pi,abs(Hw)); xlabel('frequency in pi
units);
ylabel('magnitude')
subplot(313);
plot(w/pi,angle(Hw)*180/pi);
xlabel('frequency in pi units');
ylabel('phase (degrees)')
1 a 1 z 1
H ( z) =
2 1 az 1
w=0:0.01:pi;
a1=0.9;a2=0.7;a3=0.4
Hw1=((1-a1)/2)*((1+exp(-j*w))...
./(1-a1*exp(-j*w)));
Hw2=((1-a2)/2)*((1+exp(-j*w))...
Hw3=((1-a3)/2)*((1+exp(-j*w))...
./(1-a3*exp(-j*w)));
plot(w/pi,abs(Hw1),'--',...
w/pi,abs(Hw2),':',...
w/pi,abs(Hw3));
1 a 1 z 1
H ( z) =
2 1 az 1
w=0:0.01:pi;
a1=0.9;a2=0.7;a3=0.4
Hw1=((1+a1)/2)*((1-exp(-j*w))...
./(1-a1*exp(-j*w)));
Hw2=((1+a2)/2)*((1-exp(-j*w))...
./(1-a2*exp(-j*w)));
Hw3=((1+a3)/2)*((1-exp(-j*w))...
./(1-a3*exp(-j*w)));
plot(w/pi,abs(Hw1),'--',...
w/pi,abs(Hw2),':',...
w/pi,abs(Hw3));
1 a 1 z 2
H ( z) =
2 1 b(1 a) z 1 az 2
(a) Plot the magnitude response | H (e j ) | for three different values of a = 0.3,0.6,0.9 and
b = 0.35 .
(b) Plot the magnitude response | H (e j ) | for three different values of b = 0.2,0.6,0.9
and a = 0.7 .
num=(1-exp(-j*2*w));
den1=(1-b*(1+a1)*exp(-j*w)...
+a1*exp(-j*2*w));
den2=(1-b*(1+a2)*exp(-j*w)...
+a2*exp(-j*2*w));
+a3*exp(-j*2*w));
Hw1=((1-a1)/2)*(num./den1);
Hw2=((1-a2)/2)*(num./den2);
Hw3=((1-a3)/2)*(num./den3);
a=0.7;b1=0.9;b2=0.6;b3=0.2;
den4=(1-b1*(1+a)*exp(-j*w)...
+a*exp(-j*2*w));
den5=(1-b2*(1+a)*exp(-j*w)...
+a*exp(-j*2*w));
den6=(1-b3*(1+a)*exp(-j*w)...
+a*exp(-j*2*w));
Hw11=((1-a)/2)*(num./den4);
Hw21=((1-a)/2)*(num./den5);
Hw31=((1-a)/2)*(num./den6);
subplot(211);
plot(w/pi,abs(Hw1),'--',...
w/pi,abs(Hw2),':',...
w/pi,abs(Hw3));
subplot(212);
plot(w/pi,abs(Hw11),'--',...
w/pi,abs(Hw21),':',w/pi,abs(Hw31));
1 a 1 2bz 1 z 2
H ( z) =
2 1 b(1 a) z 1 az 2
(a) Plot the magnitude response | H (e j ) | and phase response H (e j ) for three different
values of a = 0.3,0.6,0.9 and b = 0.6 .
(b) Plot the magnitude response | H (e j ) | for three different values of b = 0.2,0.6,0.9
and a = 0.7 .
w=0:0.01:pi;
a1=0.9;a2=0.6;a3=0.3; b=0.6;
num=(1-2*b*exp(-j*w)+exp(-j*2*w));
den1=(1-b*(1+a1)*exp(-j*w)...
den2=(1-b*(1+a2)*exp(-j*w)...
+a2*exp(-j*2*w));
den3=(1-b*(1+a3)*exp(-j*w)...
+a3*exp(-j*2*w));
Hw1=((1+a1)/2)*(num./den1);
Hw2=((1+a2)/2)*(num./den2);
Hw3=((1+a3)/2)*(num./den3);
a=0.7;b1=0.9;b2=0.6;b3=0.2;
num4=(1-2*b1*exp(-j*w)+exp(-j*2*w));
num5=(1-2*b2*exp(-j*w)+exp(-j*2*w));
num6=(1-2*b3*exp(-j*w)+exp(-j*2*w));
den4=(1-b1*(1+a)*exp(-j*w)...
+a*exp(-j*2*w));
den5=(1-b2*(1+a)*exp(-j*w)...
+a*exp(-j*2*w));
den6=(1-b3*(1+a)*exp(-j*w)...
+a*exp(-j*2*w));
Hw11=((1+a)/2)*(num4./den4);
Hw21=((1+a)/2)*(num5./den5);
Hw31=((1+a)/2)*(num6./den6);
subplot(211);
plot(w/pi,abs(Hw1),'--',...
w/pi,abs(Hw2),':',w/pi,abs(Hw3));
subplot(212);
plot(w/pi,abs(Hw11),'--',...
w/pi,abs(Hw21),':',w/pi,abs(Hw31));
w=0:0.01:pi;
Hapw=freqz(b,a,w);
subplot(221);zplane(b,a);
subplot(222);
plot(w/pi,abs(Hapw));
subplot(223);
plot(w/pi,angle(Hapw)*180/pi);
subplot(224);
plot(w/pi,unwrap(angle(Hapw))*180/pi);
title('Unwrapped phase');
(a) Decompose and plot the xce ( n) xce ( n) and xco (n) xco (n) components of x(n) x(n) .
N = 9; n = 0:N-1;
x = [1 2 3 4 5 6 7 8 9];
%***** xce(n)******
n1 = mod(-n,N);
y1 = x(n1+1);
xcen = (x+y1)/2;
subplot(231);
stem(n,xcen,'filled');
xlabel('n'); title('xce(n)');
%***** xco(n)******
n1 = mod(-n,N);
y1 = x(n1+1);
xcon = (x-y1)/2;
subplot(232);
stem(n,xcon,'filled');
xlabel('n'); title('xco(n)');
%****** DFT[x(n)]*****
k = 0:N-1;
Xk = x*WN; subplot(233);
stem(k,real(Xk),'filled');
xlabel('k');
title('Real[X(k)]');
subplot(234);
stem(k,imag(Xk),'filled');
xlabel('k');
title('Imag[X(k)]');
%***** DFT[xce(n)]******
WN = exp(-j*2*pi/N*n'*k);
Xcek = xcen*WN;
subplot(235);
stem(k,Xcek,'filled');
xlabel('k');
ylabel('magnitude');
title('DFT[xce(n)]');
%***** DFT[xco(n)]******
WN = exp(-j*2*pi/N*n'*k);
Xcok = xcon*WN;
subplot(236);
stem(k,imag(Xcok),'filled');
xlabel('k');
ylabel('magnitude');
title('DFT[xco(n)]');
n n
x (n) = 2 cos 2000 = 2 cos
8000 4
x (t ) = 2 cos(2000 t )
(b) Write a MATLAB program to compute the spectrum of a Hamming window function
with a window size = 100 = 100 .
(c) Write a MATLAB program to compute the spectrum of a Hanning window function
with a window size = 150 = 150 .
x=2*sin(2000*pi*[0:1:N-1]/fs);
w=boxcar(N);
xw=x.*w';
k=0:N-1;
WN=exp(-j*2*pi/N*n'*k);
Xk=xw*WN;
Xf=abs(Xk)/N;
f=k*fs/N;
subplot(121);
plot(f,Xf);
xlabel('frequency');
f=[0:1:N/2]*fs/N;
subplot(122);
plot(f,Xf(1:N/2+1));
xlabel('frequency');
x=2*sin(2000*pi*[0:1:N-1]/fs);
w=hamming(N);
xw=x.*w';
k=0:N-1;
WN=exp(-j*2*pi/N*n'*k);
Xk=xw*WN;
Xf=abs(Xk)/N;
f=k*fs/N;
subplot(121);
plot(f,Xf);
xlabel('frequency');
f=[0:1:N/2]*fs/N;
subplot(122);
plot(f,Xf(1:N/2+1));
xlabel('frequency');
x=2*sin(2000*pi*[0:1:N-1]/fs);
w=hann(N);
xw=x.*w';
k=0:N-1;
WN=exp(-j*2*pi/N*n'*k);
Xk=xw*WN;
Xf=abs(Xk)/N;
f=k*fs/N;
subplot(121);
plot(f,Xf);
xlabel('frequency');
f=[0:1:N/2]*fs/N;
subplot(122);
plot(f,Xf(1:N/2+1));
xlabel('frequency');
Solution: fftshift command is used to shift zero-frequency component to centre of spectrum, that
N
is, it shifts the DFT by 2 -point. This command is useful for visualizing the Fourier transform
with the zero-frequency component in the middle of the spectrum. This command uses the
frequency-shifting property.
2 2 N
j k n j n
Since e
N 0
x( n) = e N 2
x ( n) = e j n x( n) = ( 1) n x ( n) , we have
DFT
x( n) X ( k )
N
2 DFT
j ko n
e N
x ( n) X ( k k o N )
N
2 N
j n DFT N
e N 2
x (n) X k
N 2 N
K0=2;K1=1/4;K2=1/2;K3=1/3;
K=[K1 K2 K3];
M=length(K);
a=diag(K);
for m=2:M
for k=1:m-1
a(m,k)=a(m-1,k)+a(m,m)*a(m-1,m-k);
end
end
a=K0.*[1 a(3,:)]
a=
13 5 2
a3 (1) = 1.0833 = a3 (2) = 1.25 = a3 (3) = 0.6667 =
a3 (0) = 2 , 12 , 4 , and 3.
Hence
1
H ( z) =
13 1 5 2 1 3
1 z z z
24 8 3
M=length(A);
K(1)=A(1);
A=A/A(1);
for m=M:-1:2
K(m)=A(m);
B=fliplr(A);
A=(A-K(m)*B)/(1-K(m)*K(m));
A=A(1:m-1);
end
K(2:M)
K=
1 1 1
K1 = K2 = K3 =
Hence 4, 2 , and 3 . The all-pole lattice structure is shown in Fig. 10.2.
M 11.1 Determine the amplitude response H r (e j ) and locations of zeros of H ( z) for the given
impulse response
11 1
Solution: Since h(n) is symmetric about p = = 5 and M = 9 , this is a Type-1 linear-
2
5
H r (e j ) = a (k ) cos k
k =0
The MATLAB function freqz computes the frequency response, but we cannot determine the
h=[3 -1 -7 4 5 4 -7 -1 3];
M=length(h);n=0:M-1;
L=(M-1)/2;
a=[h(L+1) 2*h(L:-1:1)];
w=0:0.01:pi;
k=0:L;
Hr=cos(w'*k)*a';
subplot(221);stem(n,h,'filled');
xlabel('n');ylabel('h(n)');
title('Impulse response');
title('Amplitude response')
subplot(223);stem(k,a,'filled');
xlabel('n');ylabel('a(n)');
title('a(n) coefficients')
subplot(224);zplane(h,1)
xlabel('real axis');
ylabel('imaginary axis');
title('pole-zero plot')
0.8 H (e jw ) 1 0.2
H (e jw ) 0.2 0.32
Assume T = 1 sec.
T=1; Ap=-20*log10(0.8);
As=-20*log10(0.2);
wp=0.2*pi;ws=0.32*pi;
b,a = cheby1(N,Ap,Wp,'s');
Hs=tf(b,a)
numd,dend=bilinear(b,a,1/T);
Hz=tf(numd,dend,T)
w=0:0.01:pi;
Hw=freqz(numd,dend,w);
subplot(121);
plot(w/pi,abs(Hw));
xlabel('frequency in pi units');
ylabel('Magnitude');
subplot(122);
xlabel('frequency in pi units');
ylabel('Magnitude (dB)');
0.09147
s 0.4867s 0.4351 s 0.09147
3 2