简体   繁体   中英

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.

But how to do it in R ?

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

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])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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