Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Practical 7(A)

DATE:

Aim Write a matlab code for plotting magnitude and phase


:
spectrum of the system with impulse response

➢ h1(n)=(0.9)n.u(n)
h1(n) is converted into frequency response
H1(ejw)=1/(1-0.9e-jw)
➢ h1(n)=(0.5)n.u(n)
h2(n) is converted into frequency response
H2(ejw)=1/(1-0.5e-jw)

Apparatus : Matlab R2012b

Program:
clc;
clear all;
close all;
num1 = 1;
den1 =[1,-0.9];
w = -pi:pi/255:pi;
h1 = freqz(num1,den1,w)
num2 = 1;
den2 =[1,-0.5];
w = -pi:pi/255:pi;
h2 = freqz(num2,den2,w)
subplot(2,2,1)
[AX,H1,H2]=plotyy(w,real(h1),w,real(h2))
set(H1,'linestyle','--')
set(get(AX(2),'ylabel'),'string','amplitude of h2--->')
title('REAL PART')
xlabel('angular frequency--->')
ylabel('amplitude of h1--->')

Digital Signal Processing (2171003) 1|Page


subplot(2,2,2)
[AX,H1,H2]=plotyy(w,imag(h1),w,imag(h2))
set(H1,'linestyle','--')
set(get(AX(2),'ylabel'),'string','amplitude of h2--->')
title('IMAGINARY PART')
xlabel('angular frequency--->')
ylabel('amplitude of h1--->')
subplot(2,2,3)
[AX,H1,H2]=plotyy(w,abs(h1),w,abs(h2))
set(H1,'linestyle','--')
set(get(AX(2),'ylabel'),'string','amplitude of h2--->')
title('ABSOLUTE PART')
xlabel('angular frequency--->')
ylabel('amplitude of h1--->')
subplot(2,2,4)
[AX,H1,H2]=plotyy(w,angle(h1),w,angle(h2))
set(H1,'linestyle','--')
set(get(AX(2),'ylabel'),'string','amplitude of h2--->')
title('ANGLE PART')
xlabel('angular frequency--->')
ylabel('amplitude of h1--->')

Digital Signal Processing (2171003) 2|Page


Waveform:

Digital Signal Processing (2171003) 3|Page


Practical 7(B)
DATE:

Aim Write a matlab code for plotting magnitude and phase


:
spectrum of the system with frequency response

➢ H(ejw)=(1-0.5e-jw+e-3jw)/(1+0.5e-jw0.75e-2jw)

Apparatus : Matlab R2012b

Program:
clc;
clear all;
close all;
num = 1;
den =[1,-0.9];
w = -pi:pi/255:pi;
h1 = freqz(num,den,w)
subplot(2,2,1)
plot(w,real(h1))
title('REAL PART')
xlabel('angular frequency--->')
ylabel('amplitude of h1--->')
subplot(2,2,2)
plot(w,imag(h1))
title('IMAGINARY PART')
xlabel('angular frequency--->')
ylabel('amplitude of h1--->')
subplot(2,2,3)
plot(w,abs(h1))
title('ABSOLUTE PART')
xlabel('angular frequency--->')
ylabel('amplitude of h1--->')

Digital Signal Processing (2171003) 4|Page


subplot(2,2,4)
plot(w,angle(h1))
title('ANGLE PART')
xlabel('angular frequency--->')
ylabel('amplitude of h1--->')

Waveform:

Digital Signal Processing (2171003) 5|Page


Digital Signal Processing (2171003) 6|Page

You might also like