Narrow band to third octave band conversion

69 views (last 30 days)
Hi,
I'm trying to convert my narrow band data from narrow band frequency data into Third octave band data. I have two matrices, the first is a matrix of the third octave bands of interest; column 1 = lower frequency, column 2 = centre frequency and column 3 = upper frequency. The second matrix is the collected data; column 1 = narrow band frequency and column 2 is collected data.
Essentially, I'm looking to take the narrow band frequencies (column 1 of f_a) that is greater than the third octave band lower frequencies and less than upper frequencies, and take a mean average of the relevant data (column 2 of f_a), then assign that to the centre frequency in a seperate matrix.
For example, for the 100Hz third octave band, with the lower and upper frequencies being 89-112, take the mean average of f_a[68 : 84 ; 2] and assign that result to 100Hz. And all the third octave bands of interest to be placed in the same matrix if possible.
Any help would be appreciated.

Answers (1)

Mathieu NOE
Mathieu NOE on 30 Jan 2024
hello
I think I already answered a very similar question in the past
anyhow , this is one liitle function I wrote long time ago
this was for my own purpose , the fft spectrum was given in dB units
other wise , if your fft amplitudes are in linear units simply change this line
Slin_squared = 10.^(Sdb/10); % conversion dB -> lin ^2
into
Slin_squared = Slin.^2; % conversion lin -> lin ^2
I also found another one (attached) FYI
function [fto,Sto_dB] = narrowband2thirdoct(freq,Sdb)
% fft narrow band to 1/3 octave bands conversion
% within each band , we do a energy sum (sum of the squared fft amplitudes)
% then the dB is obtained by 10*log10 of the sum
% M Noé
% 04/03/2010
Slin_squared = 10.^(Sdb/10); % conversion dB -> lin ^2
% fft narrow band to 1/3 octave bands conversion
fref = [10, 12.5 16 20, 25 31.5 40, 50 63 80, 100 125 160, 200 250 315, ...
400 500 630, 800 1000 1250, 1600 2000 2500, 3150 4000 5000, ...
6300 8000 10000, 12500 16000 20000 ];
ff = (1000).*((2^(1/3)).^[-20:13]); % Exact center freq.
a = sqrt(2^(1/3)); %
f_lower = ff./a;
f_upper = ff.*a;
ind1 = find (f_lower>min(freq)); ind1 = ind1(1); % indice du premier f_lower supérieur à min(freq)
ind2 = find (f_upper<max(freq)); ind2 = ind2(end); % indice du dernier f_upper inférieur à max(freq)
ind3 = (ind1:ind2+1);
for ci = 1:length(ind3)
ind4 = find(freq>=f_lower(ind3(ci)) & freq<=f_upper(ind3(ci)));
Sto_dB(ci) = 10*log10(sum(Slin_squared(ind4))); % 1/3 octave band level in dB
fto(ci) = fref(ind3(ci)); % central frequency of the 1/3 octave band
end

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!