N point DFT or IDFT of sequence
Problem Statement :Find the N point DFT / IDFT of the given sequence x (n) .Plot the magnitude spectrum|X(K)| Vs K. (Analyze the output for different N and the same input sequence x(n). Also observe the periodicity and symmetry property) .
1: #include<stdio.h>
2: #include<conio.h>
3: #include<complex.h>
4: void main()
5: {
6: float x[20],pi=22.0/7.0;
7: complex X[20];
8: int k,n,N;
9: clrscr();
10: printf("\t\t\tDFT Fourier Transform\n");
11: printf("\nEnter the number samples in the sequence x(n), N = ");
12: scanf("%d",&N);
13: printf("\nEnter the samples of sequence x(n)\n");
14: for(n = 0; n < N; n++)
15: {
16: printf("x(%d) = ",n);
17: scanf("%f",&x[n]);
18: }
19: for(k = 0; k < N; k++)
20: {
21: X[k]=complex(0.0,0.0);
22: for(n = 0; n < N; n++)
23: {
24: complex temp=complex(0.0,-2*pi*k*n/N);
25: X[k] = X[k] + x[n]*exp(temp);
26: }
27: }
28: printf("\nThe %d point DFT of given sequence is...",N);
29: printf("\n\tReal X(k)\t\tImaginary X(k)");
30: for(k = 0; k < N; k++)
31: printf("\nX(%d) = %3.6f\t\t %3.4f",k,real(X[k]),imag(X[k]));
32: getch();
33: }
{ 0 comments... read them below or add one }
Post a Comment