#include #include #define PI 3.14159265358979323846 #define N 600 void DFT(double real[], double real_out[], double imag_out[]) { for (int k = 0; k < N; k++) { real_out[k] = 0; imag_out[k] = 0; for (int n = 0; n < N; n++) { double theta = -2 * PI * k * n / N; real_out[k] += real[n] * cos(theta); imag_out[k] += -real[n] * sin(theta); } } } int main() { double real[N]; double real_out[N]; double imag_out[N]; // Fill in your input signal here for (int i = 0; i < N; i++) { real[i] = 10+sin(i)/* real part of the signal */; } DFT(real, real_out, imag_out); // Print the output for (int i = 0; i < N/2; i++) { printf("X[%d] = %f \n", i, sqrt(real_out[i]*real_out[i]+ imag_out[i]*imag_out[i])); } return 0; }