VNRVJIET 22071A04R2
Name of the Laboratory: Digital Signal Processing Experiment No: 2
Name of the Experiment: Linear Convolution Dat e:22-11-24
Linear Convolution
AIM: To verify Linear Convolution in Code composer studio.
SOFTWARE USED: Code Composer Studio
Code:
#include<stdio.h>
int main() {
int y[7];
int N = 4;
int i, j;
int x[8] = {1, 2, 3, 4, 0, 0, 0, 0};
int h[8] = {4, 3, 2, 1, 0, 0, 0, 0};
for (i = 0; i < 2 * N - 1; i++) {
y[i] = 0;
}
for (i = 0; i < 2 * N - 1; i++) {
for (j = 0; j <= i; j++) {
if (j < N && (i - j) < N) { // Check bounds
y[i] += x[j] * h[i - j];
}
}
}
for (i = 0; i < 2 * N - 1; i++) {
printf("%d ", y[i]);
}
return 0;
}
OUTPUT:
R2
RESULT: Hence, we have verified Linear Convolution in Code composer studio.