代码拉取完成,页面将自动刷新
#define Num 8192//1024pts;
#define Pi 3.1415926535897932384626433832795028841971
#define sampleTime 0.000001//1Msps
#define BaseFreq 10000
#include <iostream>
#include <fstream>
#include <iomanip>
#include<math.h>
extern "C"
{
#include "mcu_fft.h"
}
int main()
{
double data[Num] = { 0 }, dataInt[Num] = { 0 };
data[0] = 1;
double FIR_Sequence[] = { 1.59580293420777e-05,-0.000546752692664573,
0.0011539697641281,-0.00165186352705445,0.00136270810593162,
0.000301689639400425,-0.00336736150662413,0.0068516837425501,
-0.00875374001783947,0.00673016832708933,0.000624636982277882,
-0.012389500474644,0.0245743565399063,-0.030678590719918,
0.0237063633495183,0.0009328600206886,-0.0427953869544021,
0.0953194930896113,-0.147052050766303,0.184999634419181,
0.801061092948126,0.184999634419181,-0.147052050766303,
0.0953194930896113,-0.0427953869544021,0.0009328600206886,
0.0237063633495183,-0.030678590719918,0.0245743565399063,
-0.012389500474644,0.000624636982277882,0.00673016832708933,
-0.00875374001783947,0.0068516837425501,-0.00336736150662413,
0.000301689639400425,0.00136270810593162,-0.00165186352705445,
0.0011539697641281,-0.000546752692664573,1.59580293420777e-05 };
int FIR_Seq_int[sizeof(FIR_Sequence) / sizeof(FIR_Sequence[0])] = { 0 };
std::ofstream f1("dataCos.csv");
double data_af_FIR[Num] = { 0 };
for (int i = 0; i < sizeof(data) / sizeof(data[0]); i++)
{
data[i] += 0.25 * cos(sampleTime * double(i) * 2 * Pi * 10000) + 0.25 * cos(sampleTime * double(i) * 2 * Pi * 100000) + 0.25 * cos(sampleTime * double(i) * 2 * Pi * 300000) + 0.25 * cos(sampleTime * double(i) * 2 * Pi * 460000);
data_af_FIR[i] = data[i];
}
mcu_FIR_usage(data_af_FIR, FIR_Sequence, Num, 41, 32768);
double freq_Mark_USR[Num] = { 0 };
mcu_fft_usage(data, sampleTime, Num, freq_Mark_USR);
mcu_fft_usage(data_af_FIR, sampleTime, Num, freq_Mark_USR);
for (int i = 0; i < Num; i++)
{
f1 << std::fixed << std::setprecision(4) << freq_Mark_USR[i] << "," << data[i] << "," << data_af_FIR[i] << std::endl;
}
f1.close();
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。