问题
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