⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 how_to_use_fft.c

📁 this file is even FFT, max point is 8192,this file "fft4g.c" is computer this file "how_to_use_fft.c
💻 C
字号:
#include "stdio.h"
#include <stdlib.h>

#define OFDM_TOTAL_CARRIER 8192

#ifndef NMAX
#define NMAX 8192
#define NMAXSQRT 64
#endif

typedef float fft_type;

void cdft(int, int, fft_type *, int *, fft_type *);

void test_cdft()
{
   int i, fft_length;
	int ip[NMAXSQRT + 2];
   fft_type w[NMAX * 5 / 4];
   fft_type *ofdm_data;

	FILE *fid1, *fid2;
//====== Initialization =======
   ip[0] = 0; // initial 
   fft_length = OFDM_TOTAL_CARRIER*2;
   ofdm_data = malloc(fft_length * sizeof(fft_type));
//====== End of Initialization =======




//===== assign input of fft
	for(i=0;i<fft_length;i++){
      ofdm_data[i] = i;
	}

   if( (fid1=fopen("fft_input.txt","w")) == (FILE *)NULL ){
      printf("Could not open file \n");
	}
	else{
      for(i=0;i<fft_length;i++){
         fprintf(fid1, "%f\n", ofdm_data[i]);
		}
	}

//====== compute FFT
   cdft(fft_length, -1, ofdm_data, ip, w); 

	
	if( (fid2=fopen("fft_output.txt","w")) == (FILE *)NULL ){
      printf("Could not open file \n");
	}
	else{
      for(i=0;i<fft_length;i++){
         fprintf(fid2, "%f\n", ofdm_data[i]);
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -