INVERSE DISCRETE FOURIER TRANSFORM

//INVERSE DISCRETE FOURIER TRANSFORM
#include<iostream.h>
#include<math.h>
#include<conio.h>
void main()
{
int a,b,n,N,i,k;
float C,S;
double x1[10],x2[10],R[10],I[10];
double pi=3.141592654;
cout<<“Enter the period of x[k]:”;
cin>>N;
cout<<“Enter the real values of x[k]:”;
for(i=0;i<=N-1;i++)
{
cin>>R[i];
}

cout<<“Enter the imaginary values of x[k]:”;
for(i=0;i<=N-1;i++)
{
cin>>I[i];
}

cout<<“By analytical method of IDFT:\n”;
cout<<“x[n]:”;
for(n=0;n<=N-1;n++)
{
x1[n]=0,x2[n]=0;
for(k=0;k<=N-1;k++)
{
C=cos(2*pi*k*n/N);
S=sin(2*pi*k*n/N);
if(fabs(C)<0.001)
{
C=0;
}
else
{
C=C;
}
if(fabs(S)<0.001)
{
S=0;
}
else
{
S=S;
}
x1[n]+=(R[k]*C)-(I[k]*S);
x2[n]+=(R[k]*S)-(I[k]*C);
}
a=x1[n]/N;
b=x2[n]/N;
if(b<=0)
{
cout<<“\t”<<a<<“+”<<fabs(b)<<“j\n”;
}
else
{
cout<<“\t”<<a<<“-“<<b<<“j\n”;
}
}
}

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s