Lab Report#07
AIR UNIVERSITY
DEPARTMENT OF ELECTRICAL AND COMPUTER ENGINEERING
EXPERIMENT NO#07
Lab Title: LINEAR CONVOLUTION
Student Name: Ahmed Raza Reg. No: : 210171
Objective:
Introducing students to linear convolution and its implementation in Code Composer Studio
LAB ASSESSMENT:
Excellent Good Average Satisfactory Unsatisfactory
Attributes (5) (4) (3) (2) (1)
Ability to Conduct
Experiment
Ability to assimilate the
results
Effective use of lab
equipment and
follows
the lab safety rules
Total Marks: Obtained Marks:
LAB REPORT ASSESSMENT:
Excellent Good Average Satisfactory Unsatisfactory
Attributes
(5) (4) (3) (2) (1)
Data presentation
Experimental results
Conclusion
Total Marks: Obtained Marks:
Date: 31/10/2024_ Signature:
1|Page
Digital Signal Processing
Lab Report#07
LABORATORY
EXPERIMENT NO. 7
LINEAR CONVOLUTION
Objectives:
Introducing students to linear convolution and its implementation in Code Composer Studio
Equipment required:
C6713 DSK
Power Cable
USB Cable
Code Composer Studio v5.1.0
Background Knowledge:
Convolution:
Convolution is a mathematical operation that describes the action of a linear system on a signal. The
impulse response of a Linear Time-Invariant (LTI) system completely specifies the system. More
specifically, if the impulse response of a system is known one can compute the system output for any
input signal. The output of a system to any input signal is computed by the convolution of the input
signal with the impulse response of the system. There are two types of convolution:
Linear Convolution:
The response of a discrete-time LTI system with impulse response h[n] to an input x[n] can be
computed using the convolution sum, such that:
[ ] [ ] [ ] ∑ [ ] [ ]
However, a linear convolution is also known as aperiodic convolution because the sequence x[n] and
h[n] are typically aperiodic discrete-time sequences, and of possibly infinite duration. In linear
convolution, the input signal and impulse response may or may not be equal in length. The length of
output signal is thus given by:
( ) ( ) ( )
Linear Convolution in Code Composer Studio:
Let [ ] [ ] and [ ] [ ] . To obtain y[n] by linearly
convolving x[n] with h[n], write the code for linear convolution in CCS project main file.
Result:
After successfully building the project, Click on Run and Debug to execute the file and the following
result is displayed on console window:
2|Page
Digital Signal Processing
Lab Report#07
These values can be graphed to visualize the results. First add x, h and y to the watch window and then
right click on x, click on graph option, and graph the sequence x[n]. Edit the display properties in Axes
section and add the name x[n] for y-axis.
Right click on h in the expressions window, click on graph option and graph the sequence h[n].
Edit the display properties in Axes section and add the name h[n] for y-axis.
Right click on y in the expressions window, click on graph option and graph the sequence y[n]. Edit the
display properties in Axes section and add the name y[n] for y-axis.
3|Page
Digital Signal Processing
Lab Report#07
4|Page
Digital Signal Processing
Lab Report#07
Lab Tasks:
Task# 01:
Consider the given signals:
[ ] [ ]
[ ] [ ]
Write a code in CCS which takes length of samples and amplitude of samples as input from user
and then linearly convolves x[n] and h[n] to obtain y[n]. Display the output on console and plot
x[n], h[n] and y[n].
CODE:
#include<stdio.h>
#include<math.h>
int n1;
int n2;
int temp;
int x[10];
int h[10];
int y[20];
int p,q,n,k;
void main(){
printf("Enter the length X[n] =");
scanf("%d", &n1);
printf("Enter the length h[n] =");
scanf("%d", &n2);
int i;
printf("Enter the amplitude of X[n] =");
for (i=0;i<n1;i++){
scanf("%d", &temp);
x[i]=temp;
}
int j;
printf("Enter the amplitude of h[n] =");
for (j=0;j<n2;j++){
scanf("%d", &temp);
h[j]=temp;
}
printf(" X[n] =");
for (p=0;p<n1;p++){
printf("%d", x[p]);
}
printf(" h[n] =");
5|Page
Digital Signal Processing
Lab Report#07
for (q=0;q<n2;q++){
printf("%d", h[q]);
}
for ( n=0;n<n1+n2-1;n++){
y[n]=0;
for (k=0;k<=n;k++){
y[n]=y[n]+(x[k]*h[n-k]);
}
}
printf("\ny[n] =");
for(n=0;n<n1+n2-1;n++){
printf(" %d " , y[n]);
}
}
CONSOLE:
6|Page
Digital Signal Processing
Lab Report#07
CALCULATION:
7|Page
Digital Signal Processing
Lab Report#07
OUTPUT:
X(n):
H(n):
8|Page
Digital Signal Processing
Lab Report#07
Y(n):
9|Page
Digital Signal Processing
Lab Report#07
Task# 02:
Consider the given signals:
[ ] [ ]
[ ] [ ]
Write a code in CCS which takes length of samples and amplitude of samples as input from user
and then linearly convolves x[n] and h[n] to obtain y[n]. Display the output on console and plot
x[n], h[n] and y[n].
CODE:
#include<stdio.h>
#include<math.h>
int n1;
int n2;
int temp;
int x[10];
int h[10];
int y[20];
int p,q,n,k;
void main(){
printf("Enter the length X[n] =");
scanf("%d", &n1);
printf("Enter the length h[n] =");
scanf("%d", &n2);
int i;
printf("Enter the amplitude of X[n] =");
for (i=0;i<n1;i++){
scanf("%d", &temp);
x[i]=temp;
}
int j;
printf("Enter the amplitude of h[n] =");
for (j=0;j<n2;j++){
scanf("%d", &temp);
h[j]=temp;
}
printf(" X[n] =");
for (p=0;p<n1;p++){
printf("%d", x[p]);
}
printf(" h[n] =");
10 | P a g e
Digital Signal Processing
Lab Report#07
for (q=0;q<n2;q++){
printf("%d", h[q]);
}
for ( n=0;n<n1+n2-1;n++){
y[n]=0;
for (k=0;k<=n;k++){
y[n]=y[n]+(x[k]*h[n-k]);
}
}
printf("\ny[n] =");
for(n=0;n<n1+n2-1;n++){
printf(" %d " , y[n]);
}
}
CONSOLE:
11 | P a g e
Digital Signal Processing
Lab Report#07
CALCULATION:
12 | P a g e
Digital Signal Processing
Lab Report#07
OUTPUT:
X(n):
H(n):
13 | P a g e
Digital Signal Processing
Lab Report#07
Y(n):
Conclusion:
This lab is based on concepts of convolution. By performing linear convolution,
we were able to determine the output of a system when given an input signal
and the system’s impulse response. This lab is helpful as we do convolution on
Matlab and verify the results in form of graph.
14 | P a g e
Digital Signal Processing