How to run n points FFT in R?

那年仲夏 提交于 2020-05-16 05:57:09

问题


Suppose I have a length 100 vector x, in Matlab, I can run fft(x,32) to get a length 32 complex vector.

But how to do it in R?

fft(x,32) will not work and will still return a length 100 complex vector.


回答1:


From MatLab documentation:

Y = fft(X,n) returns the n-point DFT. If no value is specified, Y is the same size as X.

If X is a vector and the length of X is less than n, then X is padded with trailing zeros to length n.

If X is a vector and the length of X is greater than n, then X is truncated to length n. ...

To achieve same result in R:

fft(x[1:32])


来源:https://stackoverflow.com/questions/38598542/how-to-run-n-points-fft-in-r

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!