How to use the log-binning of the Fourier energy spectrum?

5 views (last 30 days)
Ali Nouri
Ali Nouri on 15 Mar 2020
Commented: Ali nouri on 26 Jun 2020
Do anybody know, How to use the log-binning of the Fourier energy spectrum?

Answers (1)

Thiago Henrique Gomes Lobato
I'm not entirely sure what you mean by log-binning, but a regular interpretation for it is just to resample the fft in log-spaced bins instead of linear ones. A way to do it is to generate your log-frequency bins and then map all linear values to it's respective bins in the log scale. Something like this can do the trick, although it is not 100% optimized:
Fs = 8000;
t = 0:1/Fs:0.2;
a = sin(2*pi*1000*t)+randn(1,length(t));
A = fft(a);
A = A.*conj(A);
% Freq vectors
LinearFreq = linspace(0,Fs,length(A));
SizeLogFreq= round(length(A)/4); % Can be, theoretically, any integer
LogFreq = logspace(1,log10(Fs),SizeLogFreq);
% Mapping
Alog = zeros(1,SizeLogFreq);
for idx=1:length(A)
[~,idxLog]= min(abs(LinearFreq(idx)-LogFreq));
Alog(idxLog) = Alog(idxLog)+A(idx);
hold on
Ali nouri
Ali nouri on 26 Jun 2020
I get this errorm do you know why
Index exceeds the number of array elements (2190).

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!