求matlab中fft函数的源代码
来源:百度知道 编辑:UC知道 时间:2024/05/09 15:33:16
可能我没表达清楚,我需要的只是matlab里简单的fft原程序如何编写,不需要那么复杂的东西。虽然matlab里有可以直接调用的fft运算函数,但我需要知道这个运算函数是怎么编出来的。谢谢了,辛苦大家~~~
一般是用:type 函数名,但有些是看不到的比如fft,sin等。
给你个c++实现的fft
#include <iostream>
#include <fstream>
#include <math.h>
using namespace std;
const double PI = 3.14159265358979323846;
int n; // 数据个数 = 2的logn次方
int logn;
/// 复数结构体
struct stCompNum
{
double re;
double im;
};
stCompNum* pData1 = NULL;
stCompNum* pData2 = NULL;
/// Examda提示: 正整数位逆序后输出
int reverseBits(int value, int bitCnt)
{
int i;
int ret = 0;
for(i=0; i<bitCnt; i++)
{
ret |= (value & 0x1) << (bitCnt - 1 - i);
value >>= 1;
}
return ret;
}
void main()
{
ifstream fin("data.txt");
int i,j,k;
// input logn
fin>>logn;
// calculate n
for(i=0, n=1; i<logn; i++) n *= 2;
// malloc memory space
pData1 = new stCompNum[n];
pData2 =