📄 abcd_durations.m
字号:
function [a, b, c, d, p2, y4]=abcd_durations(p, Fs, make_plot)
% % abcd_durations: Calculates the A, B, C, and D durations for impulsive noise
% %
% % Syntax: [a, b, c, d, p2, y4]=abcd_durations(p, Fs, make_plot);
% %
% % *********************************************************************
% %
% % Description
% %
% % This program calculates the A, B, C, and D-durations for impulsive
% % noise analysis.
% %
% % The A-dureation is indicative of the frequency content of the impulse.
% %
% % Reference: Guido F. Smoorenburg, "Damage Risk Criteria for Impulsive
% % Noise," New Perspectives on Noise Induced Hearing Loss,
% % Raven Press, New York, pages(471-490) 1982
% %
% % *********************************************************************
% %
% % Input variables
% %
% % p is the sound pressure in Pa for a single channel data array
% % the default value is randn(1, 50000);
% %
% % Fs sampling rate in Hz. default value is 100000 Hz.
% %
% % make_plot=1; plots the time records and places a circle at each
% % chosen peak. Otherwise no plots are made.
% % default value is 0.
% %
% % *********************************************************************
% %
% % Output variables
% %
% % a is the A-duration in seconds
% % b is the B-duration in seconds
% % c is the C-duration in seconds
% % d is the D-duration in seconds
% % p2 is the processed data array from calculating the B-duration
% % y2 is the processed data array from calculating the D-duration
% %
% % *********************************************************************
%
% Example='';
% p=rand(10000, 1); % Pa sound pressure, single channel data array
% Fs=50000; % Hz sample rate frequency
% make_plot=0; % 0 do not make_plots default is to not make plots
% % 1 make plots
%
% [a, b, c, d, p2, y2]=abcd_durations(p, Fs, make_plot);
%
% %
% %
% % *********************************************************************
% %
% %
% % List of Dependent Subprograms for
% % abcd_durations
% %
% %
% % Program Name Author FEX ID#
% % 1) A_duration
% % 2) analytic_impulse
% % 3) B_duration
% % 4) C_duration
% % 5) D_duration
% % 6) findextrema Schuberth Schuberth 3586
% % 7) geomean2
% % 8) LMS_trim
% % 9) LMTSregor
% % 10) rand_int
% % 11) sd_round
% % 12) sub_mean
% % 13) threshold_bin_peaks
% %
% %
% % *********************************************************************
% %
% % This program was originally developed by Chucri Kardous.
% %
% % This program was written by Edward L. Zechmann
% %
% % date 11 December 2007
% %
% % modified 17 December 2007 Added comments
% %
% % modified 13 August 2008 Updated comments
% %
% % modified 21 September 2008 Check output for being empty
% % Updated Comments
% %
% %
% % *********************************************************************
% %
% % Please feel free to modify this code.
% %
% % See also: A_Duration, B_Duration, C_Duration, D_Duration
% %
if (nargin < 1 || isempty(p)) || ~isnumeric(p)
p=randn(1, 50000);
end
% If sampling rate is not specified, then
% assume a data acquisition rate of 50 KHz;
if (nargin < 2 || isempty(Fs)) || ~isnumeric(Fs)
Fs=100000;
end
if (nargin < 3 || isempty(make_plot)) || ~isnumeric(make_plot)
make_plot=0;
end
% A-duration in seconds
% % a is the A-duration
% % at2 is the prepeak crossing
% % at1 is the post peak crossing
[a, at2, at1]=A_duration(p, Fs);
% check the data array for a zero crossing after max peak
% if the signal isn't close to a zero crossing stop
% the program and return -1
if (at2 > length(p))
a=-1;
b=-1;
c=-1;
d=-1;
else
% B-duration (assuming only one impulse)
% B-duration in seconds
[b, b_all, p2]=B_duration(p, Fs);
% C-duration in seconds
[c, c2, error_cond]=C_duration(p, Fs, make_plot);
% D-duration in seconds
% (assuming only one impulse)
[d, ddd, ee, tau_fit, y2, y4]=D_duration(p, Fs, make_plot);
end
% make sure the duration are not empty
if isempty(a)
a=-1;
end
if isempty(b)
b=-1;
end
if isempty(c)
c=-1;
end
if isempty(d)
d=-1;
end
% make sure the duration are positive
a(a<0)=-1;
b(b<0)=-1;
c(c<0)=-1;
d(d<0)=-1;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -