我的目标是获得特定中心频率的 1/3 倍频程频带频率信号。我想使用 Matlab 的 octaveFilter 功能,但我希望在 1000 Hz 处获得单个 1/3 倍频程频带峰值,但计算出 1000 Hz 的最左边和最右边的非常正的声压级。
我做错了什么?
Fs = 48000; % Sampling rate
t = 0:1/Fs:1-1/Fs; % Time vector of 1 second
f = 1000; % Frequency of signal
dpres = sin(2*pi*f*t); % Signal in [Pa]
frCen = [100 300 600 800 1000 1200 1300 1600];
[Spl,frCen] = CompOctSplFreq(dpres,frCen)
figure()
semilogx(frCen,Spl,'ro-')
title('1/3-Octave Filtered SPL over Frequency')
xlabel('Center Frequency of Octave Band Filter [Hz]')
ylabel('SPL [dB]')
function [Spl,frCen] = CompOctSplFreq(dpres,frCen);
% Reads singal in pressure over time
freqNum = length(frCen);
Fs = length(dpres);
% Setting up the 1/3-octave filters for all center frequencies
for f = 1:freqNum
octaveFilterBank{f} = octaveFilter(frCen(f),'1/3 octave','SampleRate',Fs,'FilterOrder',12);
% Filtering the signal with the corresponding filters
dpresFiltered(:,f) = octaveFilterBank{f}(dpres');
% Getting the average for each filter frequency band
drms(f) = sqrt(sum(dpresFiltered(:,f).^2)/length(dpresFiltered(:,f)));
end
% Converting the root mean square pressure to SPL
pRef = 20e-06; % Reference pressure
Spl = 20*log10(drms/pRef);
end