0% found this document useful (0 votes)
15 views28 pages

DSP Manual-1

Uploaded by

rishitej811
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views28 pages

DSP Manual-1

Uploaded by

rishitej811
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 28

DSP LAB [BEC502]

VISION

To become a distinguished department by imparting quality technical education, innovation


and research to cater technological resources for industry and societal growth.

MISSION

 Nurture excellence in the field of Electronics and Communication Engineering to meet the
needs of the industry.

 Facilitate students by promoting multidisciplinary skill development, type certification


courses suitable for industry, innovation and research.

 Foster overall personality of the students and faculties by providing behavioural, professional
attitude and ethical values through state of art in Science and Technology.

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 1


DSP LAB [BEC502]

Program Outcomes (POs)


At the end of the B.E program, students are expected to have developed the following
outcomes.
PO1 Engineering Apply the knowledge of mathematics, science, engineering
Knowledge fundamentals, and an engineering specialization to the solution of
complex engineering problems.
PO2 Problem analysis Identify, formulate, research literature, and analyze complex
engineering problems reaching substantiated conclusions using first
principles of mathematics, natural sciences, and engineering
sciences.
PO3 Design/ Design solutions for complex engineering problems and design
development of system components or processes that meet the specified needs with
solutions appropriate consideration for the public health and safety, and the
cultural, societal, and environmental considerations.
PO4 Conduct Use research-based knowledge and research methods including
investigations of design of experiments, analysis and interpretation of data, and
complex synthesis of the information to provide valid conclusions.
problems
PO5 Modern Tool Create, select, and apply appropriate techniques, resources, and
Usage modern engineering and IT tools including prediction and modelling
to complex engineering activities with an understanding of the
limitations.
PO6 The Engineer Apply reasoning informed by the contextual knowledge to assess
and Society societal, health, safety, legal, and cultural issues and the consequent
responsibilities relevant to the professional engineering practice.
PO7 Environment Understand the impact of the professional engineering solutions in
and societal and environmental contexts, and demonstrate the
Sustainability knowledge of need for sustainable development.
PO8 Ethics Apply ethical principles and commit to professional ethics and
responsibilities and norms of the engineering practice.
PO9 Individual and Function effectively as an individual, and as a member or leader in
Team Work diverse teams, and in multidisciplinary settings.
PO10 Communication Communicate effectively on complex engineering activities with the
engineering community and with society at large, such as, being
able to comprehend and write effective reports and design
documentation, make effective presentations, and give and receive
clear instructions.
PO11 Project Demonstrate knowledge and understanding of the engineering and
Management management principles and apply these to one‘s own work, as a
and Finance member and leader in a team, to manage projects and in
multidisciplinary environments
PO12 Life-long Recognize the need for, and have the preparation and ability to
learning engage in independent and life-long learning in the broadest context
of technological change

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 2


DSP LAB [BEC502]

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-

charge faculty members or instructors.

5. After the completion of the experiment should return the components to the lab instructors.

6. Strictly follow the procedures for conduction of experiments.

7. Any breakdown/failure of equipment must be reported to the technical staff immediately.

8. Uniform and ID card are must.

9. Maintain silence inside the laboratory

10.Keep your belongings in designated area.

11.Wear shock–proof footwear while entering into the circuit lab

12.Chairs and stools should be kept under the workbenches when not in use.

13.Sit upright on chairs or stools, keeping feet on the floor.

14.Every student should know the location and operating procedures of all Safety equipment

including First Aid Kit and Fire extinguisher.

DONT’S:

1. Don’t eat food, drink beverages or chew gum in the laboratory.

2. Don’t touch any live terminals.

3. Don’t spread unwanted connecting wires on the table.

4. Don’t play with the instruments laid on work bench.

5. Don’t transfer equipment to other workbench or other labs without permission.

6. Don’t change connection when supply is on.

7. Don’t leave the experiment table unattended when the experimental setup supply is on.

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 3


DSP LAB [BEC502]

LAB RUBRICS FOR 25 MARKS

Sl. DESCRIPTION MARKS SCALED


No. MARKS
1. CONTINUOUS EVALUATION 35

 Observation write-up & punctuality 5


 Conduction of experiment and output 15 15
 Viva voce 5
 Record write-up 10

2. INTERNAL TEST 50 10

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 4


DSP LAB [BEC502]

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

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 5


DSP LAB [BEC502]

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.

a) Unit sample sequence

% Parameters
n = -10:10; % Range of n
x = zeros(size(n)); % Initialize sequence

% Unit Sample Sequence


x(n == 0) = 1;

% Plot
stem(n, x);
title('Unit Sample Sequence');
xlabel('n');
ylabel('x[n]');

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 6


DSP LAB [BEC502]

b) Unit step sequence

% 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

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 7


DSP LAB [BEC502]

x = a.^n; % Exponential Sequence

% 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

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 8


DSP LAB [BEC502]

% 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

y(n) = x1[n] + x2[n]


Example: audio mixer

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[n] =x 1 [n].x 2 [n]


Time Scaling:
Let y(t) is a compressed version of x(t) The signal y(t) obtained by scaling the independent
variable, time t, by a factor k is defined by

y(t) = x(kt)

 if k > 1 the signal y(t) is a compressed version of x(t)

 if, on the other hand, 0 < k < 1 the signal y(t) is an expanded (stretched) version of x(t)

Time Shift:

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 9


DSP LAB [BEC502]

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

% MATLAB program for signal addition

% Define time axis


t = -5:0.01:5;

% Define two example signals (you can modify these signals as needed)
signal1 = sin(t); % Sine wave signal
signal2 = cos(t); % Step signal

% Perform signal addition


added_signal = signal1 + signal2;

% Plot the signals


figure;

% 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;

% Plot Added Signal


subplot(3, 1, 3);
plot(t, added_signal, 'r');

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 10


DSP LAB [BEC502]

title('Added Signal (Signal 1 + Signal 2)');


xlabel('Time');
ylabel('Amplitude');
grid on;

b) Signal multiplication

% MATLAB program for signal multiplication


% Define the time axis
t = -5:0.01:5; % Time from -5 to 5 with a step of 0.01
% Define two signals (modify as needed)
signal1 = sin(t); % Signal 1: Sine wave
signal2 = cos(t); % Signal 2: Cosine wave
% Perform signal multiplication
multiplied_signal = signal1 .* signal2; % Element-wise multiplication
% Plot the signals and their multiplication
figure;
% 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;
% Plot the Multiplied Signal
subplot(3, 1, 3);
plot(t, multiplied_signal, 'r');
title('Multiplied Signal: Signal 1 * Signal 2');
xlabel('Time');
ylabel('Amplitude');
grid on;

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 11


DSP LAB [BEC502]

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]');

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 12


DSP LAB [BEC502]

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]');

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 13


DSP LAB [BEC502]

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]');

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 14


DSP LAB [BEC502]

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.

Without using conv function

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:

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 15


DSP LAB [BEC502]

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 16


DSP LAB [BEC502]

EXPERIMENT 4

Aim: Consider a causal system y(n) = 0.9y(n-1)+x(n).

b) Plot |H(ejω)| and ∠ H(ejω)


a) Determine H(z) and sketch its pole zero plot.

c) Determine the impulse response h(n).

% Part (a): Transfer Function and Pole-Zero Plot


b = [1 0]; % Coefficients of numerator
a = [1 -0.9]; % Coefficients of denominator

% Plot Pole-Zero
figure;
zplane(b, a);
title('Pole-Zero Plot of H(z)');

% Part (b): Frequency Response


[H, w] = freqz(b, a, 'half', 1024); % Compute frequency response

% Magnitude Response |H(e^j?)|


figure;
plot(w/pi, abs(H));
title('Magnitude Response |H(e^{j\omega})|');
xlabel('Normalized Frequency (\times\pi rad/sample)');
ylabel('Magnitude');

% Phase Response ?H(e^j?)


figure;
plot(w/pi, angle(H));
title('Phase Response ?H(e^{j\omega})');
xlabel('Normalized Frequency (\times\pi rad/sample)');
ylabel('Phase (radians)');

% Part (c): Impulse Response


n = 0:20; % Time indices
h = 0.9.^n; % Impulse response

figure;
stem(n, h);
title('Impulse Response h(n)');
xlabel('n');
ylabel('h(n)');

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 17


DSP LAB [BEC502]

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 18


DSP LAB [BEC502]

EXPERIMENT 5

Aim: Computation of N point DFT of a given sequence (without using built-in function) and to

plot the magnitude and phase spectrum

Theory: In mathematics, the discrete Fourier transform (DFT) converts a finite sequence of

equally-spaced samples of a function into a same-length sequence of equally-spaced samples of

the discrete-time Fourier transform (DTFT), which is a complex-valued function of frequency.

The interval at which the DTFT is sampled is the reciprocal of the duration of the input sequence.

An inverse DFT is a Fourier series, using the DTFT samples as coefficients

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

one DTFT cycle.

Example

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 19


DSP LAB [BEC502]

% Define the input sequence (you can modify this as needed)


x = [1, 2, 3, 4]; % Example sequence
N = length(x); % Number of points in DFT (assuming N is the length of the
sequence)

% Initialize the DFT result array


X = zeros(1, N);

% Compute the DFT


for k = 1:N
for n = 1:N
X(k) = X(k) + x(n) * exp(-1j * 2 * pi * (k-1) * (n-1) / N);
end
end

% Calculate magnitude and phase


magnitude = abs(X);
phase = angle(X);

% Plot the magnitude spectrum


figure;
subplot(2, 1, 1);
stem(0:N-1, magnitude);
title('Magnitude Spectrum');
xlabel('Frequency Index');
ylabel('Magnitude');
grid on;

% Plot the phase spectrum


subplot(2, 1, 2);
stem(0:N-1, phase);
title('Phase Spectrum');
xlabel('Frequency Index');
ylabel('Phase (radians)');
grid on;

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 20


DSP LAB [BEC502]

EXPERIMENT 6

Aim: Using the DFT and IDFT, compute the following for any two given sequences

a) Circular convolution b) Linear convolution

a) Circular convolution
% Define the two sequences (Example sequences)
x1 = [1 2 3 4]; % First sequence
x2 = [4 3 2 1]; % Second sequence

% Ensure the sequences are of the same length by zero-padding


N = max(length(x1), length(x2));
x1 = [x1 zeros(1, N - length(x1))];
x2 = [x2 zeros(1, N - length(x2))];

% Compute the DFT of both sequences


X1 = fft(x1);
X2 = fft(x2);

% Element-wise multiplication of the DFTs


Y = X1 .* X2;

% Compute the IDFT to obtain the circular convolution


y_circular_conv = ifft(Y);

% Display the result


disp('Circular convolution using DFT and IDFT:');
disp(y_circular_conv);

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 21


DSP LAB [BEC502]

b) Linear convolution

% Define the two sequences (Example sequences)


x1 = [1 2 3]; % First sequence
x2 = [4 3 2 1]; % Second sequence

% Determine the length of the linear convolution


N = length(x1) + length(x2) - 1;

% Zero-pad both sequences to the length of the linear convolution


x1_padded = [x1 zeros(1, N - length(x1))];
x2_padded = [x2 zeros(1, N - length(x2))];

% Compute the DFT of both zero-padded sequences


X1 = fft(x1_padded);
X2 = fft(x2_padded);

% Element-wise multiplication of the DFTs


Y = X1 .* X2;

% Compute the IDFT to obtain the linear convolution


y_linear_conv = ifft(Y);

% Display the result


disp('Linear convolution using DFT and IDFT:');
disp(y_linear_conv);

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 22


DSP LAB [BEC502]

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.

b) Circular Time Shift Property


The circular time shift property of the discrete Fourier transform (DFT) states that: For any
sequence x of length N, and an integer k such that 0 <= k < N, the DFT of the circularly shifted
sequence x_shift, where x_shift[n] = x[(n-k) mod N], is equal to the element-wise multiplication of
the DFT of x by a complex exponential sequence. Mathematically, it can be expressed as:
DFT(x_shift) = DFT(x) * exp(-j * 2 * π * k * n / N) where j is the imaginary unit, π is the
mathematical constant pi, and * represents elementwise multiplication. This property makes the
DFT a useful tool for analyzing and processing signals that have undergone circular time shifts.

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 23


DSP LAB [BEC502]

c) Circular frequency shift property


The circular frequency shift property of the discrete Fourier transform (DFT) states that: For any
sequence x of length N, and an integer k such that 0 <= k < N, the inverse DFT (IDFT) of the
element-wise multiplication of the DFT of x by a complex exponential sequence, is equal to the
circularly shifted sequence x_shift, where x_shift[n] = x[(n+k) mod N]. Mathematically, it can be
expressed as: IDFT(DFT(x) * exp(j * 2 * π * k * n / N)) = x_shift where j is the imaginary unit, π is
the mathematical constant pi, and * represents element-wise multiplication. This property makes the
DFT a useful tool for analyzing and processing signals that have undergone circular frequency
shifts.

Properties of DFT:

i) Linearity:

dft(ax(n)+by(n))=a dft(x(n))+b dft(y(n))


clc
close all
N = 4;
x =[1 4 5 7]
g = [3 6 4 2]
a=2;
b=3;
LHS= fft(a*x+b*g)
RHS= a*fft(x)+b*fft(g)

Result:

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 24


DSP LAB [BEC502]

Circular Time Shift Property


% Circular Time Shift Property
clc;
x = [1, 2, 3, 4, 5];
% Apply a circular time shift to the signal
y = circshift(x, 2);

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;

% Display each part separately


disp(result);
disp(Y(k+1));
end

Output:

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 25


DSP LAB [BEC502]

Circular Frequency Shift Property

%Circular Frequency Shift Property


clc
x = [1, 2, 3, 4, 5];
y = (abs(fft(x)));
shift=3;
d1=[0 0 0 0 0]
N = length(x);
for k=0:N-1
phase = exp(-1i*2*pi*k*shift/N);
d1(k+1)= x(k+1).*phase
end
disp('LHS');
disp(abs(fft(d1)));

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.

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 26


DSP LAB [BEC502]

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

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 27


DSP LAB [BEC502]

Faculty In-charge: Mamatha Mallesh, Dept. of ECE, VKIT 28

You might also like