我的很多项目里都要使用DFT/FFT ,所以有各类的程序,如assembly, C/C++, C# 等等。当客户需要我帮助分析离线数据时,我发现专门用 C++ 或 C# 做各种不同的程序太耗时间和精力。最快最简单的分析方法是用 matlab, 不过客户并不懂matlab, 也没有matlab。另一个选择就是excel, 把数据装入excel,用vba 处理完之后再chart 上显示出来,这是一个轻量简单的方法。
DFT 处理后的结果,可以用来计算功率 (power), 阻抗 (impedance), 谐波(harmonics) 等等。
Dim dft_Sin() As Double
Dim dft_Cos() As Double
Dim buffer() As Double
Dim N As Integer, PI As Double, temp As Double
Dim m_R As Double, m_I As Double
Dim counter As Integer
Public Sub Initialize(samplesPerCycle As Integer, harmonic As Integer)
Dim j As Integer
N = samplesPerCycle
m_R = 0
m_I = 0
ReDim dft_Sin(N)