📄 impulsive_noise_meter.m
字号:
% % 5) allstats Duane Hanselman NA
% % 6) analytic_impulse
% % 7) B_duration
% % 8) C_duration
% % 9) calc_impuls_threshold_and_index
% % 10) convert_double
% % 11) D_duration
% % 12) data_loader2
% % 13) data_outliers3
% % 14) estimatenoise John D'Errico 16683
% % 15) file_extension
% % 16) filter_settling_data
% % 17) findextrema Schuberth Schuberth 3586
% % 18) fix_YTick
% % 19) func_threshold Jing Tian 10462
% % 20) genHyper Ben Barrowes 6218
% % 21) geomean2
% % 22) get_p_q
% % 23) hilbert2
% % 24) kurtosis2
% % 25) Leq_all_calc
% % 26) LMS_trim
% % 27) LMSloc Alexandros Leontitsis 801
% % 28) LMTSregor
% % 29) localpeaks
% % 30) m_round
% % 31) moving Aslak Grinsted 8251
% % 32) nth_freq_band
% % 33) Nth_oct_time_filter2
% % 34) Nth_octdsgn
% % 35) parseArgs Malcolm Wood 10670
% % 36) peak_index
% % 37) peak_threshhold_function
% % 38) percentiles
% % 39) plot_snd_vibs
% % 40) plotpeaks
% % 41) pow10_round
% % 42) print_data_loader_configuration_table
% % 43) print_outliers_indices
% % 44) psuedo_box
% % 45) rand_int
% % 46) resample_plot
% % 47) save_a_plot2_audiological
% % 48) sd_round
% % 49) snd_peak_metrics
% % 50) sub_mean
% % 51) sub_mean2
% % 52) subaxis Aslak Grinsted 3696
% % 53) t_alpha
% % 54) t_confidence_interval
% % 55) t_icpbf
% % 56) tableGUI Joaquim Luis 10045
% % 57) threshold_bin_peaks
% % 58) wsmooth Damien Garcia NA
% %
% %
% % ********************************************************************
% %
% % Impulsive_Noise_Meter is Written by Edward L. Zechmann
% %
% % date 10 August 2007
% %
% % modified 18 December 2007 Multitude of updates. brief list of
% % major changes
% % updated the a,b,c,d duration
% % calculations
% % added the data_outliers
% % added data_loader
% % added and updated sub_mean
% % added geomean2
% % updated plot_snd_vibs
% % updated save_a_plot2_audiological
% %
% % modified 21 December 2007 Updated comments
% %
% % modified 27 December 2007 Updated peak finding process in
% % localpeaks.m
% % fixed pts_per_bin to 0.01 seconds worth
% % of data points
% %
% % modified 27 December 2007 Updated peak finding process
% % in localpeaks.m
% % fixed pts_per_bin to 0.01 seconds
% % worth of data points
% %
% % modified 8 January 2008 Updated data_loader2. Loading matlab
% % data files now prmpts the user to
% % configure the variables.
% % There is an option to use the same
% % configuration for each data file.
% %
% % modified 21 February 2008 Updated comments.
% %
% % modified 26 February 2008 Modified the array_units, updated
% % local_peaks.m, updated comments to
% % several sub programs.
% %
% % modified 17 March 2008 Added peak_alignment_tol option for
% % specifying the tolerance for aligning
% % the peaks as a fraction of the
% % peak_interval.
% %
% % modified 18 August 2008 Updated Comments.
% % Added third oct linear peaks
% %
% % modified 19 August 2008 Added input variable percent1
% % to specify threshold for
% % identifying peaks
% %
% % modified 10 September 2008 Added optional method for finding
% % impulsive Exhaust Noise
% %
% % modified 22 September 2008 Updated Comments.
% %
% % modified 10 December 2008 Upgraded the third octave band
% % filtering programs and the A and C-
% % weighting filter programs to include
% % filter settling and resampling.
% %
% % modified 11 December 2008 Upgraded the A and C-
% % weighting filter programs,
% % to include iterative filtering.
% % The filters are now very stable.
% %
% % Removed filter coefficients from input
% % and output;
% % Peaks pressures and Levels are output.
% %
% % modified 16 December 2008 For the A and C weighting filters,
% % Use convolution to make filter
% % coefficients (b and a) into
% % arrays from cell arrays .
% %
% % modified 5 January 2009 Added sub_mean to the Nth octave
% % band filters and A and C weighting
% % filters.
% %
% %
% % ********************************************************************
% %
% % Please Feel Free To Modify This Code
% %
% % See also: Continuous_Sound_and_Vibrations_Analysis, snd_peak_metrics, plot_peaks, local_peaks,
% %
% Set the default values for unspecified input variables
if (nargin < 1 || isempty(filenamesin)) || ischar(filenamesin) || (~iscell(filenamesin) && numel(filenamesin) > 1)
if ischar(filenamesin) && exist(filenamesin)
filenamesin={filenamesin};
else
[filenamesin, pathname] = uigetfile( { '*.mat','*.wav'}, 'Select the files To Process', 'MultiSelect', 'on');
cd( pathname);
if ischar(filenamesin) && isequal(exist(filenamesin), 2)
filenamesin={filenamesin};
end
end
end
if ~iscell(filenamesin) || isempty(filenamesin) || length(filenamesin) < 1
error('Must select at least 1 file to analyze');
end
if (nargin < 2 || isempty(fileout_txt)) || ~ischar(fileout_txt)
fileout_txt='data1.txt';
end
if (nargin < 3 || isempty(fileout_struct)) || ~ischar(fileout_struct)
fileout_struct='data1_struct';
end
if (nargin < 4 || isempty(save_struct)) || ~isnumeric(save_struct)
save_struct=1;
end
if (nargin < 5 || isempty(peak_interval)) || ~isnumeric(peak_interval)
peak_interval=1;
end
if (nargin < 6 || isempty(make_plot)) || ~isnumeric(make_plot)
make_plot=1;
end
if (nargin < 7 || isempty(save_plot)) || ~isnumeric(save_plot)
save_plot=1;
end
if (nargin < 8 || isempty(fig_format)) || ~isnumeric(fig_format)
fig_format=1;
end
if (nargin < 9 || ~ischar(Tool_Name))
Tool_Name='Impulsive Noise';
end
if (nargin < 10 || isempty(same_ylim)) || ~isnumeric(same_ylim)
same_ylim=1;
end
if (nargin < 11 || isempty(min_peak)) || ~isnumeric(min_peak)
min_peak=30;
end
if (nargin < 12 || isempty(sar)) || ~isnumeric(sar)
sar=0;
end
if (nargin < 13 || ~iscell(plot_str))
plot_str={'Unprotected', 'Protected'};
end
if (nargin < 14 || isempty(Align_peaks)) || ~isnumeric(Align_peaks) || logical(Align_peaks < 1)
Align_peaks=[];
end
if (nargin < 15 || isempty(portrait_landscape)) || ~isnumeric(portrait_landscape)
portrait_landscape=1;
end
if (nargin < 16 || isempty(peak_alignment_tol)) || ~isnumeric(peak_alignment_tol)
peak_alignment_tol=0.25;
end
if (nargin < 17 || isempty(percent1)) || ~isnumeric(percent1)
percent1=[];
end
if nargin < 18 || isempty(exhaust_cycle) || ~isnumeric(exhaust_cycle)
exhaust_cycle=0;
end
if nargin < 19 || isempty(sod) || ~isnumeric(sod)
sod=1;
end
num_files=length(filenamesin);
% Make sure the .txt extension is added
[filename_base, ext]=file_extension(fileout_txt);
fileout_txt=[filename_base, '.txt'];
fid=fopen(fileout_txt, 'w');
filename=cell(num_files,1);
filenum_array=ones(num_files,1);
metrics={};
durations_array=cell(num_files,1);
other_stats2=cell(num_files,1);
% Variables may be called using eval
a=[];
b=[];
ba=[];
stat_str={'Arithmetic Mean', 'Robust Mean', 'Standard Deviation','95% Confidence Interval','Median Index','Median Value','Minimum','Maximum'};
num_stats=length(stat_str);
row_names={'Channel Number'};
row_unit='';
col_name='Peak Number';
%array_names={'Peak Level Linear', 'Peak Index', 'Peak Time', 'Peak Pres. Linear', 'Peak Pres. A-Weight', 'Peak Pres. C-Weight', 'Peak Level Linear ', 'Peak Level A-Weight )', 'Peak Level C-Weight ', 'LeqA', 'LeqA8', 'LeqC', 'LeqC8', 'Leq', 'Leq8', 'Time Span', 'A-Duration', 'B-Duration', 'C-Duration', 'D-Duration', 'Kurtosis'};
%array_units={'(dB)', '(Indices)', '(s)', '(Pa)', '(Pa)', '(Pa)', '(dB)', '(dBA)', '(dBC)', '(dBA)','(dBA)', '(dBC)','(dBC)', '(dB)','(dB)', '(s)', '(s)', '(s)', '(s)', '(s)', '(No units)'};
metrics={};
metric_str={};
metric_units={};
AHAAH_str={};
other_stats={};
md={};
% initialize the input configuration cell arrays for the wav files
% and the matlab data files
default_wav_settings_in={};
default_mat_config_in={};
% initialize the data set counter
e1=0;
s={};
for e6=1:num_files;
SP=[];
% load the data file
[SP_var, vibs_var, Fs_SP_var, Fs_vibs_var, default_wav_settings_out, default_mat_config_out]=data_loader2(filenamesin{e6}, default_wav_settings_in, default_mat_config_in);
% set the default wav file setttings
% for configuring the channels
default_wav_settings_in=default_wav_settings_out;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -