DSP Manual-1
DSP Manual-1
VISION
MISSION
Nurture excellence in the field of Electronics and Communication Engineering to meet the
needs of the industry.
Foster overall personality of the students and faculties by providing behavioural, professional
attitude and ethical values through state of art in Science and Technology.
Do’s:
1. Students must bring observation/Manual book along with pen, pencil and eraser etc.
2. Students must handle the hardware kit and other components carefully as they are expensive
3. Before entering to lab, must prepare for viva for which they are going to conduct experiment.
4. Before switching on the hardware kit, the connections must be shown to one of the lab’s in-
5. After the completion of the experiment should return the components to the lab instructors.
12.Chairs and stools should be kept under the workbenches when not in use.
14.Every student should know the location and operating procedures of all Safety equipment
DONT’S:
7. Don’t leave the experiment table unattended when the experimental setup supply is on.
2. INTERNAL TEST 50 10
Table of Contents
Bloom’s
SL PAGE Taxonomy
EXPERIMENTS
NO. NO. (RBT)
Levels
Program to generate the following discrete time signals. a) Unit sample L2, L3, L4
1 sequence, b) Unit step sequence, c) Exponential sequence, d) Sinusoidal
sequence, e) Random sequence
Program to perform the following operations on signals. a) Signal L2, L3, L4
2
addition, b) Signal multiplication, c) Scaling, d) Shifting, e) Folding
Program to perform convolution of two given sequences (without using L2, L3, L4
3
built-in function) and display the signals.
and sketch its pole zero plot. b) Plot |H(ejω)| and ∠ H(ejω) c)
Consider a causal system y(n) = 0.9y(n-1)+x(n). a) Determine H(z) L2, L3, L4
4
Determine the impulse response h(n).
Computation of N point DFT of a given sequence (without using built-in L2, L3, L4
5
function) and to plot the magnitude and phase spectrum.
Using the DFT and IDFT, compute the following for any two given L2, L3, L4
6
sequences a) Circular convolution b) Linear convolution
Verification of Linearity property, circular time shift property & circular L2, L3, L4
7
frequency shift property of DFT.
Develop decimation in time radix-2 FFT algorithm without using L2, L3, L4
8
built-in functions
Design and implementation of digital low pass FIR filter using a window L2, L3, L4
9
to meet the given specifications
Design and implementation of digital high pass FIR filter using a L2, L3, L4
10
window to meet the given specifications
Design and implementation of digital IIR Butterworth low pass filter to L2, L3, L4
11
meet the given specifications.
Design and implementation of digital IIR Butterworth high pass filter to L2, L3, L4
12
meet the given specifications
Additional Programs
13
14
EXPERIMENT 1
Aim: Program to generate the following discrete time signals. a) Unit sample sequence, b)
Unit step sequence, c) Exponential sequence, d) Sinusoidal sequence, e) Random
sequence.
Theory:
Signal is a time varying physical phenomenon which is intended to convey
information. Signal is a function of one or more independent variables, which contain
some information.
Example: voice signal, video signal, signals on telephone wires etc.
System is a device or combination of devices, which can operate on signals and
produces corresponding response. Input to a system is called as excitation and output
from it is called as response. For one or more inputs, the system can have one or more
outputs.
% Parameters
n = -10:10; % Range of n
x = zeros(size(n)); % Initialize sequence
% Plot
stem(n, x);
title('Unit Sample Sequence');
xlabel('n');
ylabel('x[n]');
% Parameters
n = -10:10; % Range of n
x = double(n >= 0); % Unit Step Sequence
% Plot
stem(n, x);
title('Unit Step Sequence');
xlabel('n');
ylabel('x[n]');
c) Exponential sequence
% Parameters
n = -10:10; % Range of n
a = 0.9; % Base of the exponential
% Plot
stem(n, x);
title('Exponential Sequence');
xlabel('n');
ylabel('x[n]');
d) Sinusoidal sequence
% Parameters
n = -10:10; % Range of n
omega = pi/4; % Angular Frequency
x = sin(omega * n); % Sinusoidal Sequence
% Plot
stem(n, x);
title('Sinusoidal Sequence');
xlabel('n');
ylabel('x[n]');
e) Random sequence
% Parameters
n = -10:10; % Range of n
x = rand(size(n)); % Random Sequence
% Plot
stem(n, x);
title('Random Sequence');
xlabel('n');
ylabel('x[n]');
EXPERIMENT 2
Aim: Program to perform the following operations on signals. a) Signal addition, b) Signal
multiplication, c) Scaling, d) Shifting, e) Folding
Theory:
Addition:
Let x1[n] and x2[n] denote a pair of discrete time signals. The signal y[n] obtained by the addition
of x1[n] + x2[n] is defined as
Multiplication:
Let x1[n] and x2[n] denote a pair of discrete-time signals. The signal y[n] resulting from the
multiplication of the x1(n) and x2[n] is defined by
y(t) = x(kt)
if, on the other hand, 0 < k < 1 the signal y(t) is an expanded (stretched) version of x(t)
Time Shift:
A signal may be shifted in time by replacing the independent variable n by n-k, where k is
an integer. If k is a positive integer, the time shift results in a delay of the signal by k units of time.
If k is a negative integer, the time shift results in an advance of the signal by |k| units in time.
a) Signal addition
% Define two example signals (you can modify these signals as needed)
signal1 = sin(t); % Sine wave signal
signal2 = cos(t); % Step signal
% Plot Signal 1
subplot(3, 1, 1);
plot(t, signal1);
title('Signal 1 (Sine Wave)');
xlabel('Time');
ylabel('Amplitude');
grid on;
% Plot Signal 2
subplot(3, 1, 2);
plot(t, signal2);
title('Signal 2 (Cosine Wave)');
xlabel('Time');
ylabel('Amplitude');
grid on;
b) Signal multiplication
c) Scaling
% Define signal
n = 0:10;
x = sin(n);
% Scaling factor
k = 2;
% Scale the signal
x_scaled = k * x;
% Plot results
figure;
subplot(2,1,1);
stem(n, x);
title('Original Signal x[n]');
xlabel('n');
ylabel('x[n]');
subplot(2,1,2);
stem(n, x_scaled);
title('Scaled Signal k * x[n]');
xlabel('n');
ylabel('k * x[n]');
d) Shifting
% Define signal
n = 0:10;
x = sin(n);
% Shifting
shift_amount = 3; % Number of samples to shift
n_shifted = n + shift_amount;
% Plot results
figure;
subplot(2,1,1);
stem(n, x);
title('Original Signal x[n]');
xlabel('n');
ylabel('x[n]');
subplot(2,1,2);
stem(n_shifted, x);
title('Shifted Signal x[n-shift_amount]');
xlabel('n');
ylabel('x[n - shift_amount]');
e) Folding
% Define signal
n = 0:10;
x = sin(n);
% Folding (time-reversal)
n_folded = -n; % Reverse the time axis
x_folded = fliplr(x); % Reverse the signal values
% Plot results
figure;
subplot(2,1,1);
stem(n, x);
title('Original Signal x[n]');
xlabel('n');
ylabel('x[n]');
subplot(2,1,2);
stem(n_folded, x_folded);
title('Folded Signal x[-n]');
xlabel('n');
ylabel('x[-n]');
EXPERIMENT 3
Aim: Program to perform convolution of two given sequences (without using built-in function) and
display the signals
Theory:
The convolution sum is a fundamental concept in signal processing and systems analysis,
particularly for discrete-time signals. It is used to determine the output of a Linear Time-Invariant
(LTI) system when the input and the system's impulse response are known.
1. Convolution Sum Definition
For two discrete-time signals, x[n] (input signal) and h[n] (impulse response of the system), the
convolution sum is given by:
Where:
y[n] is the output signal.
x[k] the input signal.
h[n−k] is the shifted and flipped impulse response.
clc;
clear; x=[1 2 3 4];
h=[1 2 3 4];
m=length(x);
n=length(h);
X=[x,zeros(1,n)];
H=[h,zeros(1,m)];
for i=1:n+m-1
Y(i)=0;
for j=1:m
if(i-j+1>0)
Y(i)=Y(i)+X(j)*H(i-j+1);
else
end
end
end
disp(Y)
OUTPUT:
EXPERIMENT 4
% Plot Pole-Zero
figure;
zplane(b, a);
title('Pole-Zero Plot of H(z)');
figure;
stem(n, h);
title('Impulse Response h(n)');
xlabel('n');
ylabel('h(n)');
EXPERIMENT 5
Aim: Computation of N point DFT of a given sequence (without using built-in function) and to
Theory: In mathematics, the discrete Fourier transform (DFT) converts a finite sequence of
The interval at which the DTFT is sampled is the reciprocal of the duration of the input sequence.
of complex sinusoids at the corresponding DTFT frequencies. It has the same sample-values as
the original input sequence. The DFT is therefore said to be a frequency domain representation of
the original input sequence. If the original sequence spans all the non-zero values of a function, its
DTFT is continuous (and periodic), and the DFT provides discrete samples of one cycle. If the
original sequence is one cycle of a periodic function, the DFT provides all the non-zero values of
Example
EXPERIMENT 6
Aim: Using the DFT and IDFT, compute the following for any two given sequences
a) Circular convolution
% Define the two sequences (Example sequences)
x1 = [1 2 3 4]; % First sequence
x2 = [4 3 2 1]; % Second sequence
b) Linear convolution
EXPERIMENT 7
Aim: Verification of Linearity property, circular time shift property & circular frequency shift
property of DFT.
Proof :
a) Linearity property
The linearity property of the discrete Fourier transform (DFT) states that: For any two sequences x
and y, and any two scalars a and b, the DFT of the sequence (ax + by) is equal to (aX) + (bY),
where X and Y are the DFTs of x and y, respectively. Mathematically, it can be expressed as:
DFT(ax + by) = aDFT(x) + bDFT(y) This property makes the DFT a useful tool for analyzing and
processing linear systems.
Properties of DFT:
i) Linearity:
Result:
N = length(x);
X = fft(x);
Y = fft(y);
for k=0:N-1
phase = exp(-1i*2*pi*k*2/N);
% Calculate the expression
result = X(k+1) * phase;
Output:
disp('RHS');
disp (y);
Output:
"LHS"
2.6286556 4.253254 15. 4.253254 2.6286556
"RHS"
15. 4.253254 2.6286556 2.6286556 4.253254
EXPERIMENT 8
Aim: Develop decimation in time radix-2 FFT algorithm without using built-in functions
Theory: In DFT radix -2 FFT the time domain sequence is decimated into 2-point sequences.
For each 2-point sequence,2 -point DFT can be computed. From the result of 2-point DFT the 4-
point DFT can be calculated. From the result of 4-point DFT the 8- point DFT can be calculated.
Program:
%Code for Radix two FFT
clc;
clear ;
clf;
X=[2 1 1 2]; % Input sequence
N=length(X);
A=2 ; % no of levels
x=zeros(1,4); % appending zeros
c=[0 2 1 3]
x(1)= X(1);
x(2)= X(3);
x(3)= X(2);
x(4)= X(4);
%disp(x)
j=sqrt(-1);
N=4; % N-Point DFT
w = cos(2*pi/N*[0:(N/2-1)])-j*sin(2*pi/N*[0:(N/2-1)]);
Y1=zeros(1,2);
Y1(1)=x(1)+x(2)
Y1(2)=x(1)-x(2)
Y2=zeros(1,2);
Y2(1)=x(3)+x(4)
Y2(2)=x(3)-x(4) %disp(Y1)
%disp(Y2)
Z=zeros(1,4);
Z(1)=Y1(1)+Y2(1)
Z(2)=Y1(2)+Y2(2).*w(2)
Z(3)=Y1(1)-Y2(1)
Z(4)=Y1(2)-Y2(2).*w(2)
fprintf('Radix 2 FFT without using inbuilt function:\n');
disp(Z);
% DFT using in built function
p=fft(X);
fprintf('FFT using inbuilt function:\n');
disp(p);
OUTPUT