필터 지우기
필터 지우기

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

조회 수: 12 (최근 30일)
Ali Nouri
Ali Nouri 2020년 3월 15일
댓글: Ali nouri 2020년 6월 26일
Hi
Do anybody know, How to use the log-binning of the Fourier energy spectrum?

답변 (1개)

Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato 2020년 3월 15일
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
Thiago Henrique Gomes Lobato
Thiago Henrique Gomes Lobato 2020년 3월 15일
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
Ali nouri 2020년 6월 26일
I get this errorm do you know why
Index exceeds the number of array elements (2190).

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by