DEPARTMENT OF INSTRUMENTATION
Kurukshetra University, Kurukshetra
ELECTRICAL & INSTRUMENTATION ENGINEERING
NAME: - AYUSH ANAND ROLL NO: - 4230302 (03)
CLASS: - 6TH Sem (B. Tech)
SUBJECT: - DIGITAL SIGNAL PROCESSING LAB (EI-PRPC-22)
SUBMITTED TO: - ____________________________
Date Signature
……………….. …………………..
[Link] PARTICULARS PAGES DATE REMARKS
01. Develop a program to represent basic elementary
discrete signals.
02. Develop a program to calculate the convolution of
two discrete signals.
03. Develop a program to determine Z-transform of
given discrete signal.
04. Develop a program to determine inverse Z-
transform of given discrete signal.
05. Develop a program to describe discrete LTI system
, obtain its partial fraction and draw its pole-zero
plot.
06. Develop a program to determine impulse & step
response of a discrete system.
07. Develop a program to determine any causal signal
response of a discrete system.
08. Develop a program to determine the frequency
response of discrete LTI system.
09. Develop a program to determine Fast Fourier
Transform of given discrete signal.
10. Develop a program to obtain output response,
pole-zero plot & frequency response of the filter.
1. Devlop a program to represent basic elementary discrete signals.
clc;
close all
t=(0:0.2:10);
subplot(321)
impulse=t==0;
stem(t,impulse)
xlabel('Time Index');
ylabel('Amplitude');
title('Unit Impulse')
subplot(322)
unitstep=t>=0;
stem(t,unitstep)
xlabel('Time Index');
ylabel('Amplitude');
title('Unit Step')
subplot(323)
y3=t;
stem(t,y3)
xlabel('Time Index');
ylabel('Amplitude');
title('Unit Ramp')
subplot(324)
y4=exp(t/2);
stem(t,y4)
xlabel('Time Index');
ylabel('Amplitude');
title('Exponential')
subplot(325)
y5=sin(t);
stem(t,y5)
xlabel('Time index');
ylabel('Amplitude');
title('Sine')
subplot(326)
y6=cos(t);
stem(t,y6)
xlabel('Time Index');
ylabel('Amplitude');
title('Cosine')
1
1. Develop a program to represent basic elementary discrete signals.
1
2
2. Develop a program to calculate the convolution of two discrete
signals.
clc;
close all;
n1=input('Define the Time Index for signal-1=');
x1=input('Enter the 1st signal[x1(n1)]=');
subplot(311)
stem(x1);
xlabel('Time Index')
ylabel('Amplitude')
title('signal-1')
n2=input('Define the Time Index for signal-2=');
x2=input('Enter the 2nd signal[x2(n2)]=');
subplot(312)
stem(x2);
xlabel('Time Index')
ylabel('Amplitude')
title('signal-2')
L=length(x1)+length(x2)-1;
n=[Link]L-1;
y=conv(x1,x2);
disp('The Convolution is:')
disp(y)
subplot(313)
stem(n,y);
xlabel('Time Index');
ylabel('Amplitude');
title('Linear Convolution')
MATLAB Command Window
Define the Time Index for signal-1=([Link])
Enter the 1st signal[x1(n1)]=n1
Define the Time Index for signal-2=([Link])
Enter the 2nd signal[x2(n2)]=exp(n2/2)
The Convolution is:
1.0e+04 *
Columns 1 through 9
0 0.0001 0.0004 0.0009 0.0019 0.0036 0.0066 0.0115
0.0198
Columns 10 through 18
1
0.0335 0.0562 0.0938 0.1558 0.2582 0.4271 0.7056
1.1650 1.6243
Columns 19 through 27
2.0837 2.5431 3.0024 3.4597 3.9155 4.3689 4.8183
5.2611 5.6932
Columns 28 through 36
6.1074 6.4923 6.8287 7.0853 7.2103 7.1182 6.6684
5.6285 3.6161
>>
2
2. Develop a program to calculate the convolution of two discrete
signals.
1
3. Devlop a program to determine Z-transform of given discrete signal.
clc;
close all;
syms n;
x=input('Enter the signal(power in term of n)=');
X=ztrans(x);
disp('z transform is:');
disp(X);
% [for cross checking we calculate inverse z-transform]
Y=iztrans(X);
disp('Inverse z transform is:');
disp(Y);
MATLAB Command Window
Enter the signal(power in term of n)=2*(2^n)+4*((1/2)^n)
z transform is:
(2*z)/(z - 2) + (4*z)/(z - 1/2)
Inverse z transform is:
2*2^n + 4*(1/2)^n
>>
1
4. Develop a program to determine inverse Z-transformof given discrete
signal.
clc;
close all;
syms z;
x=input('Enter the signal(in terms of z)=');
Y=iztrans(x);
disp('Inverse z transform is:');
disp(Y);
%we cross check by calculating z-transform
X=ztrans(Y);
disp('z transform is:');
disp(X);
MATLAB Command Window
Enter the signal(in terms of z)=2*z/(z-2)^2
Inverse z transform is:
2^n + 2^n*(n - 1)
z transform is:
(2*z)/(z - 2)^2
>>
1
5. Devlop a program to describe discrete LTI system , obtain its partial
fraction and draw its pole-zero plot.
clc;
close all;
num=input('Enter the coefficient of numerator of system
func.=');
den=input('Enter the coefficient of denominator of system
func.=');
disp('Transfer Function is:');
H=tf(num,den,0.1)
disp('Zeros are:');
zeros=roots(num);
disp(zeros);
disp('Poles are:');
poles=roots(den);
disp(poles);
disp('Partial Fraction is:');
[z,p,k]=residuez(num,den)
figure(1);
zplane(num,den);
title('Pole-Zero Plot')
MATLAB Command Window
Enter the coefficient of numerator of system func.=[1 0]
Enter the coefficient of denominator of system func.
=[1 -0.25 -0.375]
Transfer Function is:
H = z
--------------------
z^2 - 0.25 z - 0.375
Sample time: 0.1 seconds
Discrete-time transfer function.
Zeros are: 0
Poles are: 0.7500
-0.5000
Partial Fraction is:
1
z = 0.6000
0.4000
p = 0.7500
-0.5000
k = []
>>
2
5. Devlop a program to describe discrete LTI system, obtain its partial
fraction and draw its pole-zero plot.
1
6. Develop a program to determine impulse & step response of a
discrete system.
clc;
close all;
n=0:0.1:10;
num=input('Enter the coefficient of numerator of system
func.=');
den=input('Enter the coefficient of denominator of system
func.=');
disp('Transfer Function is:');
H=tf(num,den,0.1)
figure(1)
impz(num,den);
title('Impulse Response')
figure(2)
stepz(num,den);
title('Step Response')
Alternate method:-
%subplot(121)
%X1=dimpulse(H,n);
%stem(X1);
%xlabel('Time Index')
%ylabel('Amplitude')
%title('Impulse Response')
%grid on
%subplot(122)
%X2=dstep(H,n);
%stem(X2);
%xlabel('Time Index')
%ylabel('Amplitude')
%title('Step Response')
%grid on;
MATLAB Command Window
Enter the coefficient of numerator of system func.=[1 0]
Enter the coefficient of denominator of system func.
=[1 -0.25 -0.375]
Transfer Function is:
1
H = z
--------------------
z^2 - 0.25 z - 0.375
Sample time: 0.1 seconds
Discrete-time transfer function.
>>
2
6. Develop a program to determine impulse & step response of a
discrete system.
1
7. Develop a program to determine any causal signal response of a
discrete system
clc;
close all;
num=input('Enter the coefficient of numerator of system
Func.=');
den=input('Enter the coefficient of denominator of system
Func. =');
disp('Transfer Function is:');
H=tf(num,den,0.1)
n=input('Define the time index of signal=');
X1=input('Enter the input signal[x(n)]=');
figure(1)
R=lsim(H,X1);
stem(R);
xlabel('Time Index');
ylabel('Amplitude');
title('Response')
grid on
MATLAB Command Window
Enter the coefficient of numerator of system Func.=[1 0]
Enter the coefficient of denominator of system Func.
=[1 -0.25 -0.375]
Transfer Function is:
H = z
--------------------
z^2 - 0.25 z - 0.375
Sample time: 0.1 seconds
Discrete-time transfer function.
Define the time index of signal=0:0.1:5
Enter the input signal[x(n)]=exp(n/2)
>>
1
7. Develop a program to determine any causal signal response of a
discrete system.
1
8. Develop a program to determine the frequency response of
discrete LTI system.
clc;
close all;
num=input('Enter the cofficients of numerator=');
den=input('Enter the cofficients of denominator=');
disp('Transfer Function is:');
H=tf(num,den,0.1)
disp('Zeros are:');
zeros=roots(num);
disp(zeros);
disp('Poles are:');
poles=roots(den);
disp(poles);
figure(1);
zplane(num,den);
title('Pole-Zero Plot')
figure(2);
freqz(num,den);
title('Frequency Response');
MATLAB Command Window
Enter the cofficients of numerator=[3 -1]
Enter the cofficients of denominator=[1 0.2 -0.35]
Transfer Function is:
H = 3 z - 1
------------------
z^2 + 0.2 z - 0.35
Sample time: 0.1 seconds
Discrete-time transfer function.
Zeros are: 0.3333
Poles are: -0.7000
0.5000
>>
1
8. Develop a program to determine the frequency response of discrete
LTI system.
1
2
9. Devlop a program to determine Fast Fourier Transform of given
discrete signal.
clc;
close all;
A=input('Enter the Amplitude of signal=');
t=(0:0.01:1);
f=input('Enter the Frequency of signal=');
wt=(2*pi*f*t);
X=input('Enter the signal as X(wt)=');
x1=A*X;
subplot(211);
plot(t,x1);
xlabel('Time Index');
ylabel('Amplitude');
title('Input Signal')
xft=fft(x1,1200);
xabs=abs(xft);
subplot(212);
plot(xabs);
xlabel('Distribution');
ylabel('Magnitude');
title(' fast Fourier Transform')
MATLAB Command Window
Enter the Amplitude of signal=1
Enter the Frequency of signal=5
Enter the signal as X(wt)=sin(wt)
>>
1
9. Devlop a program to determine Fast Fourier Transform of given
discrete signal.
1
10. Develop a program to obtain the output response , pole-zero
plots & frequency response of the filter.
clc;
close all;
num=input('Enter the coefficient of numerator=');
den=input('Enter the coefficient of denominator=');
n=input('Determine the time index for input sample=');
X=input('Enter the input sample x(n)=');
Y=filter(num,den,X);
figure(1)
zplane(num,den);
title('Pole-Zero Plot')
disp('The Output Sequence y(n)=');
disp(Y);
figure(2)
stem(Y);
xlabel('Time Index')
ylabel('Amplitude')
title('Output Sequence')
figure(3);
freqz(num,den);
title('Frequency Response');
MATLAB Command Window
Enter the coefficient of numerator=[1 0]
Enter the coefficient of denominator=[1 -0.25 -0.375]
Determine the time index for input sample=[Link]
Enter the input sample x(n)=[0 1 2 3 4 5 6 7 8 9 8 7 6 5 4
3 2 1 0]
The Output Sequence y(n)=
Columns 1 through 9
0 1.0000 2.2500 3.9375 5.8281 7.9336 10.1689
12.5173 14.9427
Columns 10 through 18
17.4297 17.9609 18.0264 17.2419 16.0704 14.4833
12.6472 10.5930 8.3910
Column 19
6.0701
>>
1
10. Develop a program to obtain the output response , pole-zero
plots & frequency response of the filter.
1
2