Unexpected results using octaveFilter
2 views (last 30 days)
Show older comments
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 Comments
Answers (0)
See Also
Categories
Find more on Audio Processing Algorithm Design in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!