Discussion:
FFT truncation
(too old to reply)
v***@gmail.com
2007-12-08 20:52:45 UTC
Permalink
Supposed that I'm only interested in the lowest 100 frequencies of a
very large time series. How would I do it in Matlab? I couldn't find
such algorithm on the internet.

Thanks
Srikanth
2007-12-09 07:17:49 UTC
Permalink
The length of the time sequence dictates the resolution of the
frequencies in the fft - if I choose a 100 sample window, the
resolution would be F/100. What I think you want is to limit the
frequencies for which the fft is calculated. Maybe fft(x,size) would
work for this...
Dong Ta
2007-12-09 21:20:35 UTC
Permalink
As I understand the Cooley-Tukey algorithm. It computes the spectrum for
each frequency independently with the computational cost log(n), doesn't
it? If so, given a set of m frequencies, can we exact the information of
those m frequencies (from the whole time series) in m*log(n)?

Thanks.
Post by Srikanth
The length of the time sequence dictates the resolution of the
frequencies in the fft - if I choose a 100 sample window, the
resolution would be F/100. What I think you want is to limit the
frequencies for which the fft is calculated. Maybe fft(x,size) would
work for this...
Bruno Luong
2007-12-09 21:41:44 UTC
Permalink
Post by Dong Ta
As I understand the Cooley-Tukey algorithm. It computes
the spectrum for
Post by Dong Ta
each frequency independently with the computational cost
log(n), doesn't
Post by Dong Ta
it?
I don't think so if you take each frequency separately. When
you do a simple scan of n data points, you already have a
complexity of n.

Bruno
Bruno Luong
2007-12-09 08:29:23 UTC
Permalink
Post by v***@gmail.com
Supposed that I'm only interested in the lowest 100
frequencies of a
Post by v***@gmail.com
very large time series. How would I do it in Matlab? I
couldn't find
Post by v***@gmail.com
such algorithm on the internet.
Simply undersampling your signal vector. i.e., use fft on
signale(1:n:end), n is apropriate number.

Bruno
Srikanth
2007-12-12 05:07:52 UTC
Permalink
Post by Bruno Luong
Simply undersampling your signal vector. i.e., use fft on
signale(1:n:end), n is apropriate number.
Bruno
Hi
Could you explain that? I haven't figured out how fft on a downsampled
version would work. If the original data is at 16khz, and you drop
alternate samples, the fft would give you a range 0-8khz (step size
depending on the length of the fft). But if you downsample a lot (say,
to limit 16khz to 1khz), you end up causing aliasing, right? Maybe I'm
missing something here...
Srikanth
Bruno Luong
2007-12-12 09:34:06 UTC
Permalink
You could do several fft on shifted downsampling vectors,
then combine the results.

Properties of fft on downsampling, shifting, etc... are
pretty wellknown, I'm sure you can find somewhere a good
book that explains it well.

Bruno

Tom Bryan
2007-12-10 15:37:54 UTC
Permalink
Post by v***@gmail.com
Supposed that I'm only interested in the lowest 100 frequencies of a
very large time series. How would I do it in Matlab? I couldn't find
such algorithm on the internet.
Thanks
If you have Signal Processing Toolbox, you can use goertzel:

help goertzel
GOERTZEL Second-order Goertzel algorithm.
GOERTZEL(X,INDVEC) computes the discrete Fourier transform (DFT)
of X at indices contained in the vector INDVEC, using the
second-order Goertzel algorithm. The indices must be integer values
from 1 to N where N is the length of the first non-singleton dimension.
If empty or omitted, INDVEC is assumed to be 1:N.

GOERTZEL(X,[],DIM) or GOERTZEL(X,INDVEC,DIM) computes the DFT along
the dimension DIM.

In general, GOERTZEL is slower than FFT when computing all the possible
DFT indices, but is most useful when X is a long vector and the DFT
computation is required for only a subset of indices less than
log2(length(X)). Indices 1:length(X) correspond to the frequency span
[0, 2*pi) radians.

EXAMPLE:
% Resolve the 1.24 kHz and 1.26 kHz components in the following
% noisy cosine which also has a 10 kHz component.
Fs = 32e3; t = 0:1/Fs:2.96;
x = cos(2*pi*t*10e3)+cos(2*pi*t*1.24e3)+cos(2*pi*t*1.26e3)...
+ randn(size(t));

N = (length(x)+1)/2;
f = (Fs/2)/N*(0:N-1); % Generate frequency vector
indxs = find(f>1.2e3 & f<1.3e3); % Find frequencies of interest
X = goertzel(x,indxs);

hms = dspdata.msspectrum((abs(X)/length(X)).^2,f(indxs),'Fs',Fs);
plot(hms); % Plot the mean-square spectrum.
Loading...