0% found this document useful (0 votes)
37 views

DSP Report

The document contains the source code of a C program that performs the discrete Fourier transform (DFT) on a sequence of numbers. It takes in the length of the sequence and the sequence values as input. It then calculates the real and imaginary parts of the DFT coefficients and prints them out. The code contains declarations for variables needed, a main function that gets the input and calls the DFT calculation in nested for loops, and output of the DFT coefficient values.

Uploaded by

Saurav Agarwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

DSP Report

The document contains the source code of a C program that performs the discrete Fourier transform (DFT) on a sequence of numbers. It takes in the length of the sequence and the sequence values as input. It then calculates the real and imaginary parts of the DFT coefficients and prints them out. The code contains declarations for variables needed, a main function that gets the input and calls the DFT calculation in nested for loops, and output of the DFT coefficient values.

Uploaded by

Saurav Agarwal
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

17BEE021

SAURAV KR. AGARWAL


#include<stdio.h>
#include<math.h>
int N,K,n,i;
float pi=3.1416, sumre=0, sumim=0, out_real[8] = {0.0},out_imag[8]={0.0};
int x[32];
void main(void)
{
printf("Enter the length of the sequence: ");
scanf("%d",&N);
printf("Enter the sequence: ");
for(i=0; i<N; i++);
{
scanf("%d",&x[i]);
}
for(K=0; K<N; K++)
{
sumre=0;
sumim=0;
for(n=0;n<N;n++)
{
sumre = sumre+x[n]*cos(2*pi*K*n/N);
sumim = sumim-x[n]*sin(2*pi*K*n/N);
}
out_real[K] = sumre;
out_imag[K] = sumim;
printf("x[%d] = \t%f\t+\t%fi\n", K, out_real[K], out_imag[K]);
}
}

Result :

[C674X_0] Enter the length of the sequence: 5


Enter the sequence: 4 5 6 7 8
x[0] = 231613184.000000 + 0.000000i
x[1] = 3195744000.000000 + -944432832.000000i
x[2] = -1763410944.000000 + -2776098560.000000i
x[3] = -1763352832.000000 + 2776145408.000000i
x[4] = 3195746560.000000 + 944363072.000000i

You might also like