我正在将 Matlab/Octave 代码移植到 C。我需要移植的实现之一是 DST 转换。 在 Matlab/Octave 中,这是使用
完成的A =[0.00000 4.24264 5.65685 7.07107 8.48528 0.00000]
res = dst(A)
ans =
22.3599 -4.7499 -4.4287 2.9465 -6.8864 1.9383
在 C 中,我已经按照 FFTW3 文档所述进行了操作:
n = 6;
fftw_plan plan = fftw_plan_r2r_1d( n, in, out, FFTW_RODFT10, FFTW_ESTIMATE);
fftw_execute ( plan );
其中 in
是输入数组。结果是,out
:
42.588457
-9.899495
0.000000
2.449490
-11.411543
5.656854
为什么这些结果如此不同?我在这里做错了什么,如果有的话,有什么想法吗?
最佳答案
如果您正在寻找完全相同的转换,您可以尝试使用 RODFT00
标志。
根据 fftw、matlab、octave 的文档,它似乎适合,除了 2 因子。 fftw 的输出可能是 matlab 或 Octave 的两倍。
http://www.mathworks.fr/fr/help/pde/ug/dst.html
http://octave.sourceforge.net/signal/function/dst.html
http://www.fftw.org/doc/1d-Real_002dodd-DFTs-_0028DSTs_0029.html
再见,
关于matlab - Matlab 中的 DST 变换与 FFTW3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22817641/