Commit 6bf10a5e authored by Mueller-Trapet's avatar Mueller-Trapet

bugfixes and additional implementation of ATSM version

parent 5a4b0eed
...@@ -8,91 +8,94 @@ function varargout = ita_soundInsulationIndexAirborne(varargin) ...@@ -8,91 +8,94 @@ function varargout = ita_soundInsulationIndexAirborne(varargin)
%% input parsing %% input parsing
sArgs = struct('pos1_data','anything','bandsperoctave',3,'freqVector',[],'createPlot',false); sArgs = struct('pos1_data','anything','bandsperoctave',3,'freqVector',[],'createPlot',false,'type','ISO');
[data,sArgs] = ita_parse_arguments(sArgs,varargin); [data,sArgs] = ita_parse_arguments(sArgs,varargin);
%% additional parameters
if sArgs.bandsperoctave == 3
refSurf = 32;
elseif sArgs.bandsperoctave == 1
refSurf = 10;
else
error([upper(mfilename) ':wrong input for badnsperoctave']);
end
refFreq = 500;
%% reference curves %% reference curves
if sArgs.bandsperoctave == 1 if strcmpi(sArgs.type,'iso') % Reference curve and frequencies according to ISO 717-1
refCurve = [36 45 52 55 56]; % Reference curve according to ISO 717-1 outputStr = 'R_W';
freq = [125 250 500 1000 2000]; % Frequencies according to ISO 717-1 roundingFactor = 0.1;
lFreq = length(refCurve); deficiencyLimit = Inf;
if sArgs.bandsperoctave == 1
refCurve = [36 45 52 55 56]-52;
freq = [125 250 500 1000 2000];
refSurf = 10;
elseif sArgs.bandsperoctave == 3
freq = [100,125,160,200,250,315,400,500,630,800,1000,1250,1600,2000,2500,3150];
refCurve = [33 36 39 42 45 48 51 52 53 54 55 56 56 56 56 56]-52;
refSurf = 32;
else
error([upper(mfilename) ':wrong input for bandsperoctave']);
end
elseif strcmpi(sArgs.type,'astm') % Reference curve and frequencies according to ASTM E413
outputStr = 'STC';
roundingFactor = 1;
deficiencyLimit = 8;
sArgs.bandsperoctave = 3;
freq = [125,160,200,250,315,400,500,630,800,1000,1250,1600,2000,2500,3150,4000];
refCurve = [-16 -13 -10 -7 -4 -1 0 1 2 3 4 4 4 4 4 4];
refSurf = 32;
else else
freq = [100,125,160,200,250,315,400,500,630,800,1000,1250,1600,2000,2500,3150]; % Frequencies according to ISO 717-1 error([upper(mfilename) ':wrong input for type']);
refCurve = [33 36 39 42 45 48 51 52 53 54 55 56 56 56 56 56]; % Reference curve according to ISO 717-1
lFreq = length(refCurve);
end end
freq = freq(:);
refCurve = refCurve(:);
dbStep = 1;
%% prepare data %% prepare data
msgExtrap = 'Sound insulation data will be extrapolated'; if ~isa(data,'itaSuper')
if isa(data,'itaSuper')
freqVector = data.freqVector;
soundInsulation = 20.*log10(interp1(freqVector,data.freqData(:,1),freq,'spline','extrap'));
else
freqVector = sArgs.freqVector; freqVector = sArgs.freqVector;
if ~isempty(freqVector) if ~isempty(freqVector)
soundInsulation = interp1(freqVector,data,freq,'spline','extrap'); % not in dB?!? data = itaResult(10.^(data(:)./20),freqVector(:),'freq');
else else
error([upper(mfilename) ':not enough input data']); error([upper(mfilename) ':not enough input data']);
end end
end end
freqVector = data.freqVector;
soundInsulation = 20.*log10(interp1(freqVector,data.freqData(:,1),freq,'spline','extrap'));
if isempty(find(freqVector <= freq(1),1,'first')) || isempty(find(freqVector >= freq(end),1,'first')) if min(freqVector) > freq(1) || max(freqVector) < freq(end)
warning(upper(mfilename),msgExtrap); warning([upper(mfilename) ': Sound insulation data will be extrapolated']);
end end
%% sound insulation index %% sound insulation index
soundInsulation = round(soundInsulation*10)/10; soundInsulation = round(soundInsulation/roundingFactor)*roundingFactor;
delta = refCurve-soundInsulation; soundInsulationIndex = min(floor(soundInsulation-refCurve));
soundInsulationIndexTest = sum(delta(delta>0)); delta = max(0,refCurve + soundInsulationIndex - soundInsulation);
counter = 0; % stopping criterion counter = 0; % stopping criterion
% shift reference curve until 32dB is reached % shift reference curve until limits are reached
Diff = 0; while sum(delta) < refSurf && counter < 1e3
while abs(soundInsulationIndexTest -refSurf)>1 && counter < 1e6 if max(delta) >= deficiencyLimit
if counter == 0 % Anpassung der refTerzkurve break;
Diff = round(mean(delta)*10)/10; elseif sum(delta) < refSurf-1
elseif sum(soundInsulationIndexTest) < refSurf-1 soundInsulationIndex = soundInsulationIndex + dbStep;
Diff = Diff+0.1;
else else
Diff = Diff-0.1; soundInsulationIndex = soundInsulationIndex - dbStep;
end end
delta = (refCurve+Diff)- soundInsulation; delta = max(0,refCurve + soundInsulationIndex - soundInsulation);
soundInsulationIndexTest = sum(delta(delta>0));
counter = counter+1; counter = counter+1;
end end
soundInsulationIndex = round((refCurve(freq == refFreq)+Diff)*100)/100; deficiencies = itaResult(delta,freq,'freq')*itaValue(1,'dB');
deficiencies.allowDBPlot = false;
%% output %% output
if sArgs.createPlot if sArgs.createPlot
plotResult = itaResult; fgh = ita_plot_freq(data);
plotResult.freqVector = freq; plotResult = itaResult([10.^((refCurve+soundInsulationIndex)./20), [ones(sum(freq<=500),1)*10.^(soundInsulationIndex./20); nan(sum(freq>500),1)]],freq,'freq');
plotResult.freqData(:,1) = 10.^((refCurve+Diff)./20); ita_plot_freq(plotResult,'figure_handle',fgh,'axes_handle',gca,'hold');
plotResult.freqData(:,3) = 10.^(soundInsulation./20); bar(gca,deficiencies.freqVector,deficiencies.freq,'hist');
plotResult.freqData(:,2) = ones(lFreq,1)*10.^(soundInsulationIndex./20); legend({'Sound transmission loss','Shifted reference curve',[outputStr ' = ' num2str(soundInsulationIndex) 'dB'],'Deficiencies'});
ylim([0 max(max(soundInsulation),max(refCurve)+soundInsulationIndex)+15]);
plotResult.channelNames{3} = 'sound insulation';
plotResult.channelNames{1} = 'shifted reference curve';
plotResult.channelNames{2} = ['R_W = ' num2str(soundInsulationIndex) 'dB'];
plotResult.plot_freq;
xlim([min(freq) max(freq)]);
end end
varargout{1} = soundInsulationIndex; varargout{1} = soundInsulationIndex;
% reference curve specified at the freqVector specified by the input itaResult: % reference curve specified at the freqVector specified by the input itaResult:
if nargout == 2 if nargout >= 2
varargout{2} = interp1(freq, 10.^((refCurve+Diff)./20), freqVector, 'linear'); varargout{2} = interp1(freq, 10.^((refCurve+soundInsulationIndex)./20), freqVector, 'linear');
if nargout == 3
varargout{3} = deficiencies;
end
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment