How to use the log-binning of the Fourier energy spectrum?
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hi
Do anybody know, How to use the log-binning of the Fourier energy spectrum?
0 commentaires
Réponses (1)
Thiago Henrique Gomes Lobato
le 15 Mar 2020
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);
end
figure,
plot(LinearFreq,A)
hold on
plot(LogFreq,Alog)
3 commentaires
Thiago Henrique Gomes Lobato
le 15 Mar 2020
N = length(Del_mat); % Del_mat is matrix of 8760X30
fs = 1;
figure(1)
s=5;
for i=1:30
y(:,i)=Del_mat(:,i);
y1(:,i) = fft(y(:,i));
power(:,i)= abs(y1(:,i)).^2/N; % power of the DFT
X_mags(:,i)=power(:,i);
X_mags(:,i)=smooth(X_mags(:,i),s);
end
bin_vals = [0 : N-1];
fax_Hz = bin_vals*fs/N;
SizeLogFreq= round(N/4); % Can be, theoretically, any integer
LogFreq = logspace(1,log10(fs),SizeLogFreq);
% Mapping
Alog = zeros(SizeLogFreq,size(Del_mat,2));
for idx=1:N
[~,idxLog]= min(abs(fax_Hz(idx)-LogFreq));
Alog(idxLog,:) = Alog(idxLog,:)+X_mags(idx,:);
end
N_2 = ceil(N/2);
for j=1:7
loglog(fax_Hz(1:N_2),X_mags((1:N_2),j))
hold on
loglog(LogFreq(1:N_2),Alog((1:N_2),j)) % May need to go beyong N/2
end
Ali nouri
le 26 Juin 2020
I get this errorm do you know why
Index exceeds the number of array elements (2190).
Voir également
Catégories
En savoir plus sur Spectral Measurements dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!