Post by v***@gmail.comSupposed 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.