/* C Program to compute Discrete Fourier Transform(DFT)
of a sequence X(n) of Length N
Inputs : 1)Number of samples of x(n) i.e. N
2)Values of samples of x(n)
Outputs: N point DFT X(k) with its real and imaginary parts.
Assumptions: The sequence x(n) is considered real.
===============================================================*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
void main()
{
float static X[100],X_Real[100],X_Imag[100];
float k,n,N;
clrscr();
printf("\t\t\t Discrete Fourier Transform(DFT)");
printf("\n\n Enter the number samples in the sequence X(n),N=");
scanf("%f",&N);
printf("\n\n Enter the samples of sequence X(n):");
for(n=0;n<N;n++)
{
printf("X(%d)=",n);
scanf("%f",&X[n]);
}
for(k=0;k<N;k++)
{
X_Real[k]=X_Imag[k]=0.0;
for(n=0;n<N;k++)
{
X_Real[k]=X_Real[k]+X[n]*cos((2*M_PI*k*n)/N);
X_Imag[k]=X_Imag[k]+X[n]*sin((2*M_PI*k*n)/N);
}
X_Imag[k]=X_Imag[k]*(-1.0);
}
printf("\n The %d point DFT of given sequence is..",N);
printf("\n\t Real X(k)\t\t Imaginary X(k)");
for(k=0;k<N;k++)
printf("\n X(%d)=%f\t\t %f",k,X_Real[k],X_Imag[k]);
getch();
}
op*******
Discrete Fourier Transform(DFT)
Enter the number samples in the sequense X(n)=4
Enter the samples of sequence X(n):
X(0)=1
X(1)=2
X(2)=0
X(3)=1
The 4 point DFT of given sequence is:
Real X[k] Imaginary X[k]
X(0)=4.000000 -0.000000
X(1)=1.000000 -1.000000
X(2)=-2.000000 -0.000000
X(3)=1.000000 1.000000
of a sequence X(n) of Length N
Inputs : 1)Number of samples of x(n) i.e. N
2)Values of samples of x(n)
Outputs: N point DFT X(k) with its real and imaginary parts.
Assumptions: The sequence x(n) is considered real.
===============================================================*/
#include<stdio.h>
#include<conio.h>
#include<math.h>
#include<graphics.h>
void main()
{
float static X[100],X_Real[100],X_Imag[100];
float k,n,N;
clrscr();
printf("\t\t\t Discrete Fourier Transform(DFT)");
printf("\n\n Enter the number samples in the sequence X(n),N=");
scanf("%f",&N);
printf("\n\n Enter the samples of sequence X(n):");
for(n=0;n<N;n++)
{
printf("X(%d)=",n);
scanf("%f",&X[n]);
}
for(k=0;k<N;k++)
{
X_Real[k]=X_Imag[k]=0.0;
for(n=0;n<N;k++)
{
X_Real[k]=X_Real[k]+X[n]*cos((2*M_PI*k*n)/N);
X_Imag[k]=X_Imag[k]+X[n]*sin((2*M_PI*k*n)/N);
}
X_Imag[k]=X_Imag[k]*(-1.0);
}
printf("\n The %d point DFT of given sequence is..",N);
printf("\n\t Real X(k)\t\t Imaginary X(k)");
for(k=0;k<N;k++)
printf("\n X(%d)=%f\t\t %f",k,X_Real[k],X_Imag[k]);
getch();
}
op*******
Discrete Fourier Transform(DFT)
Enter the number samples in the sequense X(n)=4
Enter the samples of sequence X(n):
X(0)=1
X(1)=2
X(2)=0
X(3)=1
The 4 point DFT of given sequence is:
Real X[k] Imaginary X[k]
X(0)=4.000000 -0.000000
X(1)=1.000000 -1.000000
X(2)=-2.000000 -0.000000
X(3)=1.000000 1.000000
None of the program is working.
ReplyDeleteUseless programs
ReplyDelete