简体   繁体   English

如何在R中运行n点FFT?

[英]How to run n points FFT in R?

Suppose I have a length 100 vector x, in Matlab , I can run fft(x,32) to get a length 32 complex vector. 假设我有一个长度为100的向量x,在Matlab ,我可以运行fft(x,32)来获得长度为32的复数向量。

But how to do it in R ? 但是如何在R做到这一点?

fft(x,32) will not work and will still return a length 100 complex vector. fft(x,32)将不起作用,仍将返回长度为100的复矢量。

From MatLab documentation: 来自MatLab文档:

Y = fft(X,n) returns the n-point DFT. Y = fft(X,n)返回n点DFT。 If no value is specified, Y is the same size as X. 如果未指定任何值,则Y与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. 如果X是向量并且X的长度小于n,则用尾随零填充X到长度n。

If X is a vector and the length of X is greater than n, then X is truncated to length n. 如果X是向量并且X的长度大于n,则X被截断为长度n。 ... ...

To achieve same result in R: 为了在R中获得相同的结果:

fft(x[1:32])

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM