0% found this document useful (0 votes)
24 views2 pages

Experiment No:-3: AIM: - To Perform Discrete Convolution

The document describes an experiment to perform discrete convolution on two sequences. It defines variables to store the lengths and values of the input sequences, as well as the output sequence. It checks if the sequences are of equal length, and pads the smaller with zeros if needed. Two loops are used to calculate the circular convolution: one to calculate the first element of the output, and a nested loop to calculate the remaining elements by circularly shifting one input sequence on each iteration. The result is then printed.

Uploaded by

Nikita Gaikwad
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)
24 views2 pages

Experiment No:-3: AIM: - To Perform Discrete Convolution

The document describes an experiment to perform discrete convolution on two sequences. It defines variables to store the lengths and values of the input sequences, as well as the output sequence. It checks if the sequences are of equal length, and pads the smaller with zeros if needed. Two loops are used to calculate the circular convolution: one to calculate the first element of the output, and a nested loop to calculate the remaining elements by circularly shifting one input sequence on each iteration. The result is then printed.

Uploaded by

Nikita Gaikwad
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/ 2

EXPERIMENT NO :- 3

AIM :- To perform Discrete Convolution.

#include<stdio.h>
int m,n,x[30],h[30],y[30],i,j, k,x2[30],a[30];

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 length of both sequences are not equal*/
{ if(m>n) /* Pad the smaller sequence with zero*/
{ for(i=n;i<m;i++)
h[i]=0;
n=m; }
for(i=m;i<n;i++)
x[i]=0;
m=n; }
y[0]=0;
a[0]=h[0];
for(j=1;j<n;j++) /*folding h(n) to h(-n)*/
a[j]=h[n-j]; /*Circular convolution*/
for(i=0;i<n;i++)
y[0]+=x[i]*a[i];
for(k=1;k<n;k++)
{ y[k]=0;
/*circular shift*/
for(j=1;j<n;j++)
x2[j]=a[j-1];
x2[0]=a[n-1];
for(i=0;i<n;i++)
{ a[i]=x2[i];
y[k]+=x[i]*x2[i];} } /*displaying the result*/
printf(" the circular convolution is\n");
for(i=0;i<n;i++)
printf("%d \t",y[i]);
}
OUTPUT

enter the length of the first sequence


4
enter the length of the second sequence
4
enter the first sequence
1234
enter the second sequence
5678
the circular convolution is 66 68 66 60

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy