/*-------------INVERSE DISCRETE FOURIER TRANSFORM(IDFT)---------------
This program computes the IDFT of N point X(k).
Inputs: 1) Length of DFT i.e. N.
2) Real and imaginary parts of DFT X(k).
Outputs: N point sequence i.e. x(n).
Assumptions: The sequence x(n) is considered real.
=======================================================================*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float static X[100],X_Real[100],X_Imag[100];
float k,n,N;
clrscr();
printf("\t\t\t Inverse Discrete Fourier Transform(IDFT)");
printf("\n\n Enter the length of DFT N=");
scanf("%f",&N);
printf("\n Enter the real and imaginary parts of X(k) as follows:\n\n"
"X(k) =Real{X(k)} Img{X(k)} \n" );
for(k=0;k<N;k++)
{
printf("X(%1.0f)=",k);
scanf("%f%f",&X_Real[k],&X_Imag[k]);
}
for(n=0;n<N;n++)
{
X[n]=0;
for(k=0;k<N;k++)
{
X[n]=X[n]+X_Real[k]*cos((2*M_PI*k*n)/N)-X_Imag[k]*sin((2*M_PI*k*n)/N);
}
X[n]=X[n]/N;
}
printf("\n\n The sequence x(n) is as follows...");
for(n=0;n<N;n++)
{
printf("\n\n X(%1.0f)=%3.6f",n,X[n]);
}
getch();
}
***op******** Inverse Discrete Fourier Transform(IDFT)
Enter the length of DFT N=4
Enter the real and imaginary parts of X(k) as follows:
X(k) =Real{X(k)} Img{X(k)}
X(0) = 4 0
X(1) = 1 -1
X(2) = -2 0
X(3) = 1 1
The sequence x(n) is as follows...
X(0)=1.000000
X(1)=2.000000
X(2)=-0.000000
X(3)=1.000000
This program computes the IDFT of N point X(k).
Inputs: 1) Length of DFT i.e. N.
2) Real and imaginary parts of DFT X(k).
Outputs: N point sequence i.e. x(n).
Assumptions: The sequence x(n) is considered real.
=======================================================================*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
float static X[100],X_Real[100],X_Imag[100];
float k,n,N;
clrscr();
printf("\t\t\t Inverse Discrete Fourier Transform(IDFT)");
printf("\n\n Enter the length of DFT N=");
scanf("%f",&N);
printf("\n Enter the real and imaginary parts of X(k) as follows:\n\n"
"X(k) =Real{X(k)} Img{X(k)} \n" );
for(k=0;k<N;k++)
{
printf("X(%1.0f)=",k);
scanf("%f%f",&X_Real[k],&X_Imag[k]);
}
for(n=0;n<N;n++)
{
X[n]=0;
for(k=0;k<N;k++)
{
X[n]=X[n]+X_Real[k]*cos((2*M_PI*k*n)/N)-X_Imag[k]*sin((2*M_PI*k*n)/N);
}
X[n]=X[n]/N;
}
printf("\n\n The sequence x(n) is as follows...");
for(n=0;n<N;n++)
{
printf("\n\n X(%1.0f)=%3.6f",n,X[n]);
}
getch();
}
***op******** Inverse Discrete Fourier Transform(IDFT)
Enter the length of DFT N=4
Enter the real and imaginary parts of X(k) as follows:
X(k) =Real{X(k)} Img{X(k)}
X(0) = 4 0
X(1) = 1 -1
X(2) = -2 0
X(3) = 1 1
The sequence x(n) is as follows...
X(0)=1.000000
X(1)=2.000000
X(2)=-0.000000
X(3)=1.000000
when i try to compile this code, my compiler says it cannot use a float type as an index for arrays, what can i do?
ReplyDelete