/* Program for CIRCULAR CONVOLUTION of two sequences h(n) and x(n).
Inputs: 1) Length of two sequences N.
2) Samples of two seqquences.
Output: Circular Convolution sequence of h(n) and x(n).
Assumptions: The given sequence are real and causal.
====================================================================*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int N,M,n,k,m;
float total,h[20],x[20],y[20];
clrscr();
printf("\n\t\t\t Circular Convolution\n\n\n");
printf("\n Enter the value of N=");
scanf("%d",&N);
printf("\n\n Enter the sequence h(n):");
for(n=0;n<N;n++)
{
printf("\n\n h[%d]=",n);
scanf("%f",&h[n]);
}
printf("\n\n Enter the sequence x(n):");
for(n=0;n<N;n++)
{
printf("\n\n x[%d]=",n);
scanf("%f",&x[n]);
}
printf("\n\n\n Circular convolution is:");
for(m=0;m<N;m++)
{
total=0.0;
for(k=0;k<N;k++)
{
if((m-k)>=0)
n=m-k;
else
n=m-k+N;
total=total+x[k]*h[n];
}
y[m]=total;
printf("\n\n y[%d]=%f",m,y[m]);
}
getch();
}
Circular Convolution
Enter the value of N=4
Enter the sequence h(n):
h[0]=2
h[1]=1
h[2]=2
h[3]=1
Enter the sequence x(n):
x[0]=1
x[1]=2
x[2]=3
x[3]=4
Circular convolution is:
y[0]=14.000000
y[1]=16.000000
y[2]=14.000000
y[3]=16.000000
Inputs: 1) Length of two sequences N.
2) Samples of two seqquences.
Output: Circular Convolution sequence of h(n) and x(n).
Assumptions: The given sequence are real and causal.
====================================================================*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
int N,M,n,k,m;
float total,h[20],x[20],y[20];
clrscr();
printf("\n\t\t\t Circular Convolution\n\n\n");
printf("\n Enter the value of N=");
scanf("%d",&N);
printf("\n\n Enter the sequence h(n):");
for(n=0;n<N;n++)
{
printf("\n\n h[%d]=",n);
scanf("%f",&h[n]);
}
printf("\n\n Enter the sequence x(n):");
for(n=0;n<N;n++)
{
printf("\n\n x[%d]=",n);
scanf("%f",&x[n]);
}
printf("\n\n\n Circular convolution is:");
for(m=0;m<N;m++)
{
total=0.0;
for(k=0;k<N;k++)
{
if((m-k)>=0)
n=m-k;
else
n=m-k+N;
total=total+x[k]*h[n];
}
y[m]=total;
printf("\n\n y[%d]=%f",m,y[m]);
}
getch();
}
Circular Convolution
Enter the value of N=4
Enter the sequence h(n):
h[0]=2
h[1]=1
h[2]=2
h[3]=1
Enter the sequence x(n):
x[0]=1
x[1]=2
x[2]=3
x[3]=4
Circular convolution is:
y[0]=14.000000
y[1]=16.000000
y[2]=14.000000
y[3]=16.000000
I want this code in python can u please send me?
ReplyDeleteit is too lengthy
ReplyDeleteWill you provide calculations
ReplyDelete