Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

DSP File

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 26

SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Experiment No.- 2

Aim: To develop a program to generate a unit step function.

Apparatus: MATLAB software

Theory:
The step signal or step function is that type of standard signal which exists only for positive time
and it is zero for negative time. In other words, a signal x(t) is said to be step signal if and only if
exists for t > 0 and zero for t < 0. If a step signal has unity magnitude, then it is known as unit step
signal or unit step function. It is denoted by u(t).

Mathematically it is represented as,

{
U (t )= 1 , t ≥ 0
0 ,∧t <0

Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.

Program:
t = -20 : 0.001 : 20;

y = heaviside(t);

plot(t, y, ‘Linewidth’, 3)

axis([-10 10 -2 2])

xlabel(‘t’)

ylabel(‘u(t)’)

title(‘Plot of Unit Step Function’)

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Experiment No.- 2

Aim: To develop a program to generate a unit step function.

Apparatus: MATLAB software

Representation:

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Experiment No.- 3

Aim: To develop a program to generate a unit step sequence.

Apparatus: MATLAB software

Theory:
The step sequence is that type of standard signal which exists only for positive discrete instants
and it is zero for negative discrete instants. In other words, a sequence u(n) is said to be step
sequence if and only if exists for n ≥ 0 and zero for n < 0. If a step sequence has unity magnitude,
then it is known as unit step sequence. It is denoted by u(n).

Mathematically it is represented as,

{
U ( n)= 1 ,n ≥ 0
0 ,∧n< 0

Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.

Program:
n = -10 : 20;

s = [ zeros(1,10) ones(1,21)];

stem(n, s);

xlabel(‘n’);

ylabel(‘u(n)’);

title(‘Representation of Unit Step Sequence’);

axis([-10 20 0 1.2]);

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Experiment No.- 3

Aim: To develop a program to generate a unit step sequence.

Apparatus: MATLAB software

Representation:

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Experiment No.- 4

Aim: To develop a program for discrete time Unit Ramp signal.

Apparatus: MATLAB software

Theory:
The discrete time unit ramp signal is that function which starts from n = 0 and increases
linearly. It is denoted by r(n). It is signal whose amplitude varies linearly with time n.
Mathematically, the discrete time unit ramp sequence is defined as-

{
r ( n ) = n ,∧for n ≥0
0 ,∧for n< 0

also r ( n ) =n∗u (n)

Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.

Program:

Method I: Method II:


n = 0:20;
n = -10:1:10;
y = n;
z = (n>=0).*n; stem(n,y)
xlabel(“n”);
stem(n,z)
ylabel(“Amplitude”);
xlabel(“n”);
title(“Unit Ramp Sequence”);
ylabel(“Amplitude”);

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
title(“Unit Ramp Sequence”);

Experiment No.- 5

Aim: To develop a program for discrete time Unit Impulse signal.

Apparatus: MATLAB software

Theory:
The discrete time unit impulse sequence δ (n), also called the unit Sample sequence, is
defined as,

{
δ ( n )= 1 , for n=0
¿ 0 , for n≠ 0

Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.

Program:
n = -20:20;

delta_n = [zeros(1,20) 1 zeros(1,20)]

stem(n,delta_n)

xlabel(“n”);

ylabel(“Amplitude”);

title(“Unit Impulse Signal);

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Experiment No.- 6

Aim: To develop a program to add two sequences.

Apparatus: MATLAB software

Theory:
In MATLAB we can add or subtract discrete time signals to study them.

Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.

Program:
sequence1 = [1, 2, 3, 4, 5];

sequence2 = [6, 7, 8, 9, 10];

if length(sequence1) ~= length(sequence2)

error('Sequences must have the same length');

end

result = sequence1 + sequence2;

figure;

subplot(3, 1, 1);

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
stem(sequence1, 'filled', 'LineWidth', 2);

title('Sequence 1');

xlabel('Index');

ylabel('Value');

subplot(3, 1, 2);

stem(sequence2, 'filled', 'LineWidth', 2);

title('Sequence 2');

xlabel('Index');

ylabel('Value');

subplot(3, 1, 3);

stem(result, 'filled', 'LineWidth', 2);

title('Result');

xlabel('Index');

ylabel('Value');

Representation:

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Experiment No.- 7

Aim: To develop program for computing Z-transform.

Apparatus: MATLAB software

Theory:
In mathematics and signal processing, the Z-transform converts a discrete-time signal,
which is a sequence of real and complex numbers, into a complex frequency-domain
representation.

The Z-transform of a discrete-time signal x(n) is defined by



X (Z )= ∑ x(n)z−n
n=−∞

Where z = rejw is a complex variable. The value of z for which the sum converges define a region
in the Z-plane referred to as the region of convergence(ROC).

Procedure:

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.

Program:
Method-I (Using for loop) Method-II (Using Z-transform function)
X = [1 2 3 4 5]; syms n
L = length(x); f = sin(n);
Z = sym(‘Z’);s r = ztrans(f);
for i = 0:L-1 disp(‘Z-transform using function’);
X = X + X(i+1)*Z-i; disp(r);
end
disp(‘displaying output’);
disp(X);

Representation:

By using both Method-I and Method-II.

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Experiment No.- 8

Aim: To develop program for computing inverse Z-transform.

Apparatus: MATLAB software

Theory:

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
The inverse Z-transform is defined as the process of finding the time domain signal x(n)
from its Z-transform X(z). Then inverse Z-transform is denoted as-
−n
x ( n )=Z [ X ( z )]

Where, z is a complex variable and is given by, Z = rejw

Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.

Program:
syms n
f = sin(n);
z = ztrans(f);
disp(‘ztransform of sin(n) is’);
disp(z);
zz = iztrans(z);
disp(‘displaying inverse z transform);
disp(zz);

Representation:

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Experiment No.- 9

Aim: Write a program in MATLAB to verify linear convolution.

Apparatus: MATLAB software

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Theory:
In case of convolution two signal sequences input signal x(n) and impulse response h(n)
given by the same system, output y(n) is calculated by multiplication of two sequences in time
domain is called as Linear Convolution.
Linear Convolution is given by the equation
y(n) = x(n)*h(n)
and calculated as,


y (n) = ∑ ❑
x ( k ) h(n−k )
k =−∞

Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.

Program:
x1 = [1 2 3 4];
x2 = [2 4 3 1 5 6 8];
y = conv(x1,x2);
subplot(311)
stem(‘x1’)
xlabel(‘n’);
ylabel(‘x1[n]’);
title(‘vector x1’)
subplot(312)
stem(‘x2’)
xlabel(‘n’);

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
ylabel(‘x2[n]’);
title(‘vector x2’)
subplot(313)
stem(‘y’)
xlabel(‘n’);
ylabel(‘y[n]’);
title(‘Linear convolution’)

Representation:

Experiment No.- 10

Aim: To develop program for computing DFT and IDFT.

Apparatus: MATLAB software

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Theory:
DFT- The N-point DFT of a finite duration sequence of length L, where N≥L is defined
as,
DFT ¿ ;k=0,1,2,…..,N-1

IDFT- The Inverse Discrete Fourier Transform of sequence X(k) of length N is defined
as:
N−1 j2πnk
1
IDFT [ X ( K ) ] =x ( n )=
N
∑ X (k )e N
; n= 0,1,2,….,N-1
k=0

Procedure:
1. The program is entered in the MATLAB Editor and is saved with the *.m
extension.
2. The program is executed in the Command Window/editor window.
3. If any error is reported then debug it and again execute it from Command
Window/Editor Window.
4. Input if required is entered from the command Window.
5. The result is displayed in the command window.

Program:
xn = input(‘Enter the input sequence’)
n = length(xn)
n =0:1:N-1;
subplot(2,2,1)
stem(n,xn)
xlabel(‘time’)
ylabel(‘amplitude’)
title(‘Input sequence’)
xk = fft(xn,N)
disp(kx)
k=0:1:N-1;
subplot(2,2,2)

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023
SARDAR BEANT SINGH STATE UNIVERSITY GURDASPUR
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
stem(k,xk)
xlabel(‘time’)
ylabel(‘amplitude’)
title(‘DFT’)
X=ifft(xk,N)
disp(X)
n=0:1:N-1;
subplot(2,2,3)
stem(n,x)
xlabel(‘time’)
ylabel(‘amplitude’)
title(‘IDFT’)

Representation: For input sequence xn =[1 2 3 4 5], thus N=5

Rajinder Kumar(21305006) BTEC-21506 Digital Signal Processing Lab


5th Semester (2021 Batch) July-Dec 2023

You might also like