Screenshot 2025-05-28 at 10.22.11 AM
Screenshot 2025-05-28 at 10.22.11 AM
Staff in-charge:
Dr. Kumar P
Dr. Vinay N A
Prof. Kavitha S G
Prof. Shala Shoal
Lab Instructors: Mrs. Veena and Mrs. Gayathri
ii
iii
About the College
The Dayananda Sagar College of Engineering was established in 1979 by Sri R. Dayananda Sagar.
Dayananda Sagar College of Engineering operates under the aegis of the Mahatma Gandhi Vidya
Peetha Trust is approved by All India Council for Technical Education (AICTE), Govt. of India and
affiliated to Visvesvaraya Technological University. It has the widest choice of engineering
branches having 20 Under Graduate courses & 6 Post Graduate courses. In addition, it has 20
Research Centres in different branches of Engineering catering to research scholars for obtaining
Ph.D under VTU. Various courses are accredited by NBA.
The Institute is spread over 23 acres of land with large infrastructure supported by laboratories
with state-of-the-art, Equipment & Machines. The Central Library with modern facilities and the
Digital Library provides the knowledge base for the students.
The campus is WI-FI equipped with large bandwidth internet facility. The College has good faculty
strength with highest professional integrity and committed to the academics with transparency
in their actions. Each faculty takes the responsibility of mentoring a certain number of students’
through personal attention paving the way for the students’ professional growth. The faculty are
research oriented having number of sponsored R & D projects from different agencies such as
Department of Science & Technology, Defense R & D organizations, Indian Space Research
Organization, AICTE etc..
Department of Electronics and Communication Engineering is one of the oldest and biggest
department in the DSI group with 50 faculty members and 1200+ students. Most of our faculty
have pursued Ph.D. and others are in the process. The ECE department provides high-quality,
innovative technical education at the undergraduate, graduate, and research levels. At present,
the department offers an UG course (BE) with an intake of 240, a PG course in VLSI Design and
Embedded Systems with an intake of 18 students and Ph.D. The department has got an excellent
infrastructure with sophisticated labs, class rooms and R & D center. The department faculty and
support personnel are dedicated towards helping students achieve success in today's world by
offering them the knowledge and skills required. The department places a strong emphasis on
leading-edge research through its research centre and research forum. These factors together
enable our graduating students to create a big impact on the workforce from day one.
In addition to offering innovative courses, the department is more focused on improving
students' educational experiences by offering value-added courses, skill-development programs,
technical challenges and hackathons at state, national, and international arenas. Through its
professional societies and technical clubs, the department takes great satisfaction in exposing its
students to current industry developments and upcoming technologies. The dedicated staff at
the ECE department help students procure jobs in prestigious companies both domestically and
abroad.
iv
Vision of the College:
To impart quality technical education with a focus on Research and Innovation emphasizing on
Development of Sustainable and Inclusive Technology for the benefit of society.
v
2. Problem Analysis: Identify, Formulate, Review research literature, and analyze complex
engineering problems reaching substantiated conclusions using first principles of Mathematics,
natural sciences and engineering sciences.
3. Design/Development of solutions: Design solutions for complex engineering problems and
design system components or processes that meet the specified needs with appropriate
consideration for the public health and safety, and the cultural, societal, and environmental
conditions.
4. Conduct investigations on complex problems: Use research based knowledge and research
methods including design of Experiments, analysis and interpretation of data, and synthesis of
Information to provide valid conclusions.
5. Modern tool usage: Create, select, and apply appropriate technique, resources, and modern
engineering and IT tools including prediction and modeling to complex engineering activities with
an understanding of the limitations.
6. The Engineer and Society: Apply reasoning informed by the contextual knowledge to assess
society, health, safety, legal and cultural issues and the consequent responsibilities relevant to
the professional engineering practice.
7. Environment and sustainability: Understand the impact of the professional engineering solutions
in societal and environmental contexts, and demonstrate the knowledge of, and need for
sustainable development.
8. Ethics: Apply ethical principles and commit to professional ethics and responsibilities and norms
of the engineering practice.
9. Individual and team work: Function effectively as an individual, and as a member or leader in
diverse teams, and in multidisciplinary settings.
10. 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.
11. Project management and finance: Demonstrate knowledge and understanding of the
engineering and management principles and apply these to one’s work, as a member and leader
in a team, to manage projects and in multidisciplinary environments.
12. Lifelong learning: Recognize the need for, and have the preparation and ability to engage in
independent and life-long learning in the broadest context of technological change.
vi
DEPARTMENT of ELECTRONICS AND COMMUNICATION ENGINEERING
DIGITAL SIGNAL PROCESSING(INTEGRATED) LABORATORY
Index Sheet
vii
DEPARTMENT of ELECTRONICS AND COMMUNICATION ENGINEERING
DIGITAL SIGNAL PROCESSING(INTEGRATED) LABORATORY
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
viii
Digital Signal Processing Lab
Experiment 1
Computation of Circular Convolution Using DFT and FFT
Aim: To study the computation of Circular Convolution with real time sequences.
Objective:
a. To study how Circular convolution using DFT and IDFT provides an efficient computational
approach compared to direct time-domain convolution, especially for long sequences.
b. To analyse how Circular convolution is suitable for handling periodic or circularly
extended signals.
Theory:
• Circular convolution is cyclic convolution of two sequences of same length.
• If the length of the sequences are unequal then required no.of zeros are padded.
• There are three ways to compute circular convolution:
(i). Using DFT and IDFT: Let x(n) and h(n) are the sequences, then
N−1
MATLAB code
clc;
clear all;
close all;
% Display results
disp('Circular Convolution using DFT (without FFT):');
disp(z);
subplot(4,1,2);
stem(y, 'filled');
title('Input Sequence y');
xlabel('Index');
ylabel('Amplitude');
grid on;
subplot(4,1,4);
stem(imag(z), 'filled');
title('Imaginary Part of Circular Convolution');
xlabel('Index');
ylabel('Amplitude');
grid on;
Results:
Assignment
1. Write the MATLAB code to compute circular convolution of two sequence using fft
function.
3|Dept. of ECE, DSCE
Digital Signal Processing Lab
Experiment 2
Verification of Parseval’s theorem
Aim: Write MATLAB code to verify the Parseval’s theorem
Objectives:
• To establish energy conservation between the time domain and frequency domain
representations of a signal.
• To provide an equivalence between the power of a signal in the time domain and its power
spectral density in the frequency domain.
• To study how Parseval’s theorem used in signal reconstruction tasks, especially in
applications such as signal processing, data compression, and digital communications.
Theory:
Parseval's Theorem is a concept in Fourier analysis and signal processing, stating that the total
energy in a signal is equal to the sum of the square of its Fourier transform's magnitude.
∞ ∞
1
∑ x(n)x ∗ (n) = ∑ X(k)X ∗ (k)
N
n=−∞ n=−∞
∞
∗ (𝐭)
𝟏 ∞
∫ 𝐱(𝐭)𝐱 = ∫ 𝐗(𝛚)𝐗 ∗ (𝛚)
−∞ 𝟐𝛑 −∞
MATLAB Code:
clc;
clear all;
close all;
% Display results
disp('Verification of Parseval’s Theorem:');
disp(['Energy in Time Domain: ', num2str(energy_time)]);
4|Dept. of ECE, DSCE
Digital Signal Processing Lab
Results:
Verification of Parseval’s Theorem:
Energy in Time Domain: 30
Energy in Frequency Domain: 30
Assignment:
1. Write the MATLAB code to verify the Parseval’s theorem for a continuous time signal
Experiment 3
Verification of Time Shifting Property of DFT
Aim: Write MATLAB code to verify the Time Shifting Property of DFT
Objectives:
• To validate the correctness of the time-shifting property of the DFT.
• To analyze the effects of time shifts on signals in the frequency domain and understanding
these effects is crucial for designing robust signal processing systems capable of handling
time-varying signals accurately and efficiently.
• By incorporating the time-shifting property into system design and analysis, engineers can
optimize signal processing algorithms and architectures to meet specific performance
requirements and constraints.
Theory:
The time-shifting property of discrete-time Fourier transform states that:
If DFT{x(n)} ↔ X(K), then
% Display results
disp('Verification of Time Shifting Property of DFT:');
disp('DFT of time-shifted sequence:');
disp(X_shifted);
disp('Expected DFT after applying phase shift:');
disp(X_expected);
subplot(3,1,2);
stem(x_shifted, 'filled');
title('Time-Shifted Sequence');
xlabel('Index');
ylabel('Amplitude');
grid on;
Results
Assignment:
1. Write the MATLAB code to verify the time-shifting property of DFT by choosing n0 =
1 𝑎𝑛𝑑 3
Experiment 4
Verification of Auto-correlation and Cross-correlation
Aim: Write the MATLAB code to verify the Auto-correlation and Cross-correlation of the given
signal/sequence.
Objectives:
• Autocorrelation is to analyse the similarity and periodicity within a signal and Cross
correlation is to analyse the alignment of signals in time or phase.
• Autocorrelation is used to estimate time delays between different parts of a signal. The
cross-correlation estimates the time delay between two signals.
• Autocorrelation is used in system identification to estimate the impulse response of a linear
time-invariant (LTI) system. In communication systems, cross-correlation is used for
channel estimation.
Theory:
The autocorrelation function is defined as the measure of similarity or coherence between a signal
and its time delayed version. Therefore, the autocorrelation is the correlation of a signal with itself.
∞
Autocorrelation{x(t)} = Y(τ) = ∫ x(t)x ∗ (t − τ)dτ
−∞
The cross-correlation between two different signals or functions or waveforms is defined as the
measure of similarity or coherence between one signal and the time-delayed version of another
signal. The cross-correlation between two different signals indicates the degree of relatedness
between one signal and the time-delayed version of another signal.
∞
Cross − correlation{x(t) ∗ h(t)} = Y(τ) = ∫ x(t)h∗ (t − τ)dτ
−∞
clc;
clear all;
close all;
% Display results
disp('Verification of Auto-correlation and Cross-correlation:');
disp('Auto-correlation sequence:');
disp(Rxx);
disp('Cross-correlation sequence:');
disp(Rxy);
subplot(3,1,2);
stem(y, 'filled');
title('Input Sequence y');
xlabel('Index');
ylabel('Amplitude');
grid on;
figure;
stem(Rxy, 'filled');
title('Cross-correlation of x and y');
xlabel('Index');
ylabel('Amplitude');
grid on;
Results:
Auto-correlation sequence:
30 24 22 24
Cross-correlation sequence:
20 26 28 26
10 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
Assignment:
1. Write the MATLAB code to compute the cross-correlation of two sequences.
11 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
Experiment 5
Computation of Fast Fourier Transform
Aim: Write the MATLAB code to compute Fast Fourier Transform of the sequence and plot it
magnitude and phase response.
Objectives:
• To study how FFT is more efficient with respect to less computation time compare to DFT
technique.
• To analyse the magnitude and phase spectrum of the signal.
Theory:
The Fast Fourier Transform (FFT) stands as a seminal advancement in computational
mathematics, particularly within the domain of signal processing. Fundamentally, the FFT is an
algorithmic marvel devised to efficiently compute the Discrete Fourier Transform (DFT) of a
discrete sequence or signal.
N−1
The most commonly used version of the FFT is the Radix-2 FFT, where the size of the input
sequence N is a power of 2. In Radix-2 FFT, the sequence is recursively divided into two halves,
and the DFT of each half is computed independently. The computed DFTs are then combined using
twiddle factors (complex exponentials) to produce the final DFT of the entire sequence.
The FFT algorithm can be implemented using either decimation-in-time (DIT) or decimation-in-
frequency (DIF) approaches. In DIT FFT, the sequence is recursively divided into smaller
subproblems in the time domain. In DIF FFT, the sequence is recursively divided in the frequency
domain. Both approaches are mathematically equivalent but may have different computational
characteristics.
MATLAB Code to compute FFT using formula or direct method
clc;
clear all;
close all;
12 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
% Display results
disp('Computation of Fast Fourier Transform using Direct Method:');
disp('FFT of input sequence:');
disp(X);
disp('Reconstructed sequence using IFFT:');
disp(x_reconstructed);
Results:
13 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
DIT-FFT
clc;
clear all;
close all;
% Bit-reversal permutation
num_stages = log2(N)
x_reordered = bitrevorder(x)
14 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
end
end
% Display results
disp('Computation of FFT using DIT-FFT with Even-Odd Splitting:');
disp('FFT of input sequence:');
disp(X);
disp('Reconstructed sequence using IFFT:');
disp(x_reconstructed);
grid on;
Results:
num_stages = 2
x_reordered = [1 3 2 4]
DIF-FFT
clc;
clear all;
close all;
% Perform DIF-FFT
X = complex(x)
num_stages = log2(N)
16 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
for n = 0:half_step-1
pos = k + n;
temp = X(pos);
twiddle = W_N^n * X(pos + half_step);
X(pos) = temp + twiddle;
X(pos + half_step) = temp - twiddle;
end
end
end
% Bit-reversal permutation
X = bitrevorder(X);
% Display results
disp('Computation of FFT using DIF-FFT:');
disp('FFT of input sequence:');
disp(X);
disp('Reconstructed sequence using IFFT:');
disp(x_reconstructed);
ylabel('Magnitude');
grid on;
Results:
num_stages = 2
Assignment:
1. Write the MATLAB code to compute FFT of the sequence using inbuilt FFT function.
18 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
Experiment 6
Design of IIR Filter
Aim: To design the IIR Butterworth approximation technique and to analyse the response of the
same
Objectives:
• The primary objectives of designing a Butterworth filter is to achieve a maximally flat
frequency response in the passband.
• Butterworth filters are designed to be stable and causal, ensuring that the output of the
filter does not grow indefinitely and is dependent only on past and present inputs.
• Another objective is to achieve a smooth roll-off in the stopband, where the attenuation of
frequencies outside the passband gradually increases.
• The design aims to minimize the width of the transition band, which is the frequency range
between the passband and stopband.
Theory:
The Butterworth filter is an analogue filter design which produces the best output response with
no ripple in the pass band or the stop band resulting in a maximally flat filter response but at the
expense of a relatively wide transition band.
clc;
clear all;
close all;
omp=2*passband_frequency/fs;
oms=2*stopband_frequency/fs;
%to find cut off frequency & order of the filter
[N,Wn]=buttord(omp,oms,passband_ripple,stopband_attenuation)
disp('order of the filter n =');
disp(N);
disp('cut off frequency Wn= ');
disp(Wn);
19 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
subplot(2,1,1);
plot(om/pi,20*log(m));
grid;
ylabel('gain in dB');
xlabel('normalized frequency');
subplot(2,1,2);
plot(om/pi,an);
grid;
ylabel('phase in radian');
xlabel('normalized frequency');
% to convert analog filter to digital filter
% using bilinear transformation
[bz,az]=bilinear(b,a,fs)
Output:
N=
Wn =
0.5083
b=
a=
bz =
20 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
az =
H_digital =
Assignment:
1. Write the MATLAB code to design IIR Butterworth high pass filter.
21 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
Experiment 7
Design of FIR Filter using Hamming window
Aim: Write the MATLAB code to design the high pass FIR filter using Hamming and to analyse its
plot frequency response.
Objectives:
• The primary objective is to design the FIR filter to meet specific frequency response
requirements.
• The objective is to select a window function that minimizes mainlobe width while
simultaneously suppressing sidelobes to an acceptable level.
• The FIR filter design should be robust to variations in filter parameters, such as changes in
cutoff frequencies, passband ripple, or stopband attenuation.
• To achieve linear phase while meeting the frequency response specifications, ensuring
minimal phase distortion in the filtered output.
MATLAB Code using hamming window
clc;
wp=0.3*pi;
ws=0.45*pi;
ap=-3;
as=-50;
wt=ws-wp;
n1=ceil((8*pi)/wt);
wc=wp/pi;
N=n1+rem(n1-1,2);
disp(N);
wn=hamming(N);
disp(wn);
a=(N-1)/2;
h=fir1(N-1,wc,wn); % fir1 function will calculate both hd(n) and h(n)
disp(h);
figure;
freqz(h);
figure;
n=0:N-1;
stem(n,h);
xlabel('time axis');
ylabel('h(n)');
title('impulse response of FIR lowpass filter');
disp(wn)
Output
22 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
w(n) =>
0.0800, 0.0831, 0.0924, 0.1077, 0.1289, 0.1557, 0.1876, 0.2243, 0.2653,
0.3100, 0.3578,
0.4081, 0.4601, 0.5133, 0.5667, 0.6199, 0.6719, 0.7222, 0.7700, 0.8147,
0.8557, 0.8924,
0.9243, 0.9511, 0.9723, 0.9876, 0.9969, 1.0000, 0.9969, 0.9876, 0.9723,
0.9511, 0.9243,
0.8924, 0.8557, 0.8147, 0.7700, 0.7222, 0.6719, 0.6199, 0.5667, 0.5133,
0.4601, 0.4081,
0.3578, 0.3100, 0.2653, 0.2243, 0.1876, 0.1557, 0.1289, 0.1077, 0.0924,
0.0831, 0.0800
The Order of the filter have been designed and verified. Window function
coefficients are calculated and verified. Also, Filter response is obtained and
verified forsymmetry.
23 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
Experiment 8
IEEE 32-bit floating point conversions
Given:
x=0.560123
1. Multiply by 215=327682
0.560123×32768=18364.94
18365
18365=01000111100011012
clc;
clear all;
close all;
% Unsigned Q15 Representation (Assuming the range is [0,1] mapped to [0, 2^16-1])
Q15_unsigned = round((x + 1) * (2^15)); % Shift by +1 for unsigned range
% Display results
disp(['Decimal: ', num2str(x)]);
disp(['Signed Q15 Representation (Decimal): ', num2str(Q15_signed)]);
disp(['Signed Q15 Representation (Binary): ', Q15_signed_binary]);
disp(['Unsigned Q15 Representation (Decimal): ', num2str(Q15_unsigned)]);
disp(['Unsigned Q15 Representation (Binary): ', Q15_unsigned_binary]);
Results:
Decimal: -0.16012
Signed Q15 Representation (Decimal): -5247
Signed Q15 Representation (Binary): 1110101110000001
Unsigned Q15 Representation (Decimal): 27521
Unsigned Q15 Representation (Binary): 0110101110000001
24 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
Part B
Introduction to TMS320C6713 DSK
The C6713 DSK has a TMS320C6713 DSP onboard that allows full-speed
verification of codewith Code Composer Studio. The C6713 DSK provides:
• A USB Interface
• SDRAM and ROM
• An analog interface circuit for Data conversion (AIC)
• An I/O port
• Embedded JTAG emulation support
Connectors on the C6713 DSK provide DSP external memory interface (EMIF)
and peripheral signals that enable its functionality to be expanded with
custom or third party daughter boards.
The DSK provides a C6713 hardware reference design that can assist you in
the developmentof your own C6713-based products. In addition to providing
a reference for interfacing the DSP to various types of memories and
peripherals, the design also addresses power, clock, JTAG, and parallel
peripheral interfaces.
The C6713 DSK includes a stereo codec. This Analog Interface Circuit (AIC) has
the followingcharacteristics:
The DSK includes 4 LEDs and 4 DIP switches as a simple way to provide the user with
interactive feedback. Both are accessed by reading and writing to the CPLD registers.
An included 5V external power supply is used to power the board. On-board voltage
regulatorsprovide the 1.26V DSP core voltage, 3.3V digital and 3.3V analog voltages. A
voltage supervisor monitors the internally generated voltage, and will hold the board in
reset until the supplies are within operating specifications and the reset button is
released. If desired, JP1 andJP2 can be used as power test points for the core and I/O
power supplies.
Code Composer communicates with the DSK through an embedded JTAG emulator with
a USB host interface. The DSK can also be used with an external emulator through the
externalJTAG connector.
26 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
28 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
3. In the 1st column, under My system right click and remove the processor, click Yes.
29 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
5. Click on save and quit (Left side down), then click -> Yes.
30 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
10. Save the file in your folder, save in -> Local disk (C) -> CCStudio_v3.1 -> MyProjects -> your project (xyz) -> with name
and extension.c. For example: xyz.c
11. Add the saved file to your project by right click on Source -> Add files to project
Browsing the file from your poject, Look in -> Local disk (C) -> CCStudio_v3.1 -> My Projects -> your project (xyz) -> File
(xyz.c) -> open
12. To add the library file to the project right click on libraries-> add files to project
Look in -> Local disk (C) -> CCStudio_v3.1 -> C6000 -> cgtools -> lib -> rts6700, open
31 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
13. To add the command file to the project right click on source -> add files to project
Look in -> Local disk (C) -> CCStudio_v3.1 -> tutorial -> dsk6713 -> hello1 (*File of type -> Linker Command file) -> hello
15. Build the program by clicking on Project -> Build Target, or Rebuild target
shortcut key is F7
16. File->load program. One pop up window will appear their open Debug folder -> Select your project name file with .out
extension -> open
17. Debug->Run
32 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
33 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
EXPERIMENT-01
LINEAR CONVOLUTION
AIM:- To compute the linear convolution of the given input sequence x(n) & the impulse response of the system
h(n) using “c- programming”.
#include<stdio.h>
int y[20];
main()
{
int m=3;
int n=4;
int i=0,j;
int x[15]={1,2,3,4,0,0,0,0,0,0};
int h[15]={1,2,3,0,0,0,0,0,0};
for(i=0;i<m+n-1;i++)
{ y[i]=0;
for(j=0;j<=i;j++)
y[i]+=x[j]*h[i-j];
}
for(i=0;i<m+n-1;i++)
printf("%d\n",y[i]);
}
Figure:
34 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
Linear Convolution for Two Sequences is Calculated and Verified using CodeComposer Studio and
DSP Hardware Kit.
35 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
EXPERIMENT-02
CIRCULAR CONVOLUTION
Aim: - To compute the circular convolution of the given twosequences using “c-programming”.
#include<stdio.h>
int m,n,x[30],h[30],y[30],i,j,k;
void main()
{
printf(" Enter the length of the first sequence\n");
scanf("%d",&m);
printf(" Enter the length of the second sequence\n");
scanf("%d",&n);
printf(" Enter the first sequence\n");
for(i=0;i<m;i++)
scanf("%d",&x[i]);
printf(" Enter the second sequence\n");for(j=0;j<n;j++)
scanf("%d",&h[j]);
if(m-n!=0)
{
if(m>n)
{
for(i=n;i<m;i++)
h[i]=0;
n=m;
}
for(i=m;i<n;i++)
x[i]=0;
m=n;
}
printf("the circular convolution is\n");
for(i=0;i<n;i++)
{ y[i]=0;
for(j=0;j<n;j++)
{
36 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
k=i-j;
if(k<0)
k=k+n;
y[i]=y[i]+x[j]*h[k];
}
printf("%d \t",y[i]);
}
}
Figure:
Circular Convolution for Two Sequences is Calculated and Verified using CodeComposer Studio
and DSP Hardware Kit.
37 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
EXPERIMENT-03
N-Point DFT
AIM: - To compute the n (=4/8/16) point dft of the given sequenceusing “c- programming”.
#include<stdio.h>
#include<math.h>
short N=4;
short x[4]={2,3,4,5};
float pi=3.1416; float
sumre=0;
float sumim=0;
float cosine=0;
float sine=0;
float out_sumre[8]={0.0};
float out_sumim[8]={0.0};
void main()
{
int n,k=0;
for(k=0;k<N;k++)
{
sumre=0;
sumim=0;
for(n=0;n<N;n++)
{
cosine=cos(2*pi*k*n/N);
sine=sin(2*pi*k*n/N);
sumre=sumre+x[n]*cosine;
sumim=sumim-x[n]*sine;
}
out_sumre[k]=sumre;
out_sumim[k]=sumim;
printf("[%d] %7.3f %7.3f\n\n",k,out_sumre[k],out_sumim[k]);
}
}
38 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
[0] 14.000, 0.000, [1] -2.000, 2.000, [2] -2.000, 0.000, [3] -2.000, -2.000
39 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
1. Write the C program to compute linear convolution for the given sequences.
x(n)=(-4,3,2) h(n)=(5, 6, 7, 8)
2. Write the C program to compute circular convolution for the given sequences.
x(n)=(2,5) h(n)=(3,4,8,7).
3. Write the C program to compute N point DFT for the given sequences.
x(n)=(1,8,5,3) h(n)=(2,3,4,7).
40 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
Experiment 01
Compare frequency response of FIR Filter using various window function in SIMULINK/MATLAB
MATLAB code:
clc;
clear all;
close all;
n=20;
fp=200;
fs=600;
f=1000;
wp=2*(fp/f)
ws=2*(fs/f)
wn=[wp,ws]
%window=boxcar(n+1); % rectangular window
%window=bartlett(n+1);% traiangular window
%window=hamming(n+1);% hamming wondow
%window= hanning(n+1);% hanning window
window= kaiser(n+1); % kasiser window
wn=2*(fp/fs)
%b=fir1(n,wn,window)
b=fir1(n,wn,'high',window)
[H,w]=freqz(b,1)
subplot(2,1,1)
plot(w/pi, 20*log(abs(H)))
xlabel('nf')
ylabel('mag in dB')
title("mag response")
subplot(2,1,2)
plot(w/pi, angle(H))
xlabel('nf')
ylabel('mag in dB')
title("phase response")
41 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
SIMULINK MODEL
42 | D e p t . o f E C E , D S C E
Digital Signal Processing Lab
43 | D e p t . o f E C E , D S C E