Unexpected results using octaveFilter
2 次查看(过去 30 天)
显示 更早的评论
I'm aiming at obtaining a 1/3 octave band frequency signal for specific centre frequencies. I want to use Matlab's octaveFilter functionality but I was expecting to get a single 1/3 octave band peak at 1000 Hz, but instead far left and far right of 1000 Hz very positive sound pressure levels were computed.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/193011/image.jpeg)
What do I wrong?
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
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Audio Processing Algorithm Design 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!