📄 main_sound.m
字号:
if isempty(percent1_cell)
percent1=75;
else
percent1=ceil(str2double(percent1_cell{1}));
if percent1 > 100
percent1=90;
end
if percent1 < 0
percent1=[];
end
end
else
percent1=[];
end
% % ********************************************************************
%
% Get whether an interrupted exhaust cycle should be identified as an
% impulsive noise.
%
exhaust_cycle=menu('Identify the impulses of an interrupted exhaust cycle as impulsive noises?', 'Yes', 'No', 'Default');
if ~isequal(exhaust_cycle, 1)
exhaust_cycle=0;
end
% % ********************************************************************
%
% Determine whether to Surpress Outlier Detection
%
sod=menu({'Identify Outliers and Remove them from Calculations of the Mean, STD, etc.', 'Allow Automated Detection and Removal of Anomalous Data.'}, 'Yes', 'No', 'Default');
if isequal(sod, 2)
sod=1;
else
sod=0;
end
% % ********************************************************************
%
% Determine whether to print a summary table of the statistics
%
flag2=menu('Print a summary table of statistics to a text file?', 'Yes', 'No', 'Default');
if isequal(flag2, 2)
flag2=0;
else
flag2=1;
end
% % ********************************************************************
%
% Determine whether to print the Metrics for each channel, Difference of Values, or both
%
if isequal(flag2, 1)
% % *******************************************************************
%
% Determine whether to print the Values, Difference of values, or both
%
flag=menu('Select whether to Write to text file the Metrics, Difference of Metrics, or both?', 'Metrics for each channel', 'Difference in Metrics for each pair of Channels', 'Both Metrics and Differences in Metric', 'Default (Both)');
if flag >= 3
flag=3;
end
% % *******************************************************************
%
% Get the filenames to save the text file and the matlab structures.
%
prompt= {'Enter the File Name for the Output Text file'};
defAns={'metrics_stats',};
dlg_title='Enter File Name for the Summary Descriptive Statistics';
num_lines=1;
options.Resize='on';
options.WindowStyle='normal';
options.Interpreter='tex';
file_name_cell = inputdlg(prompt,dlg_title,num_lines,defAns,options);
if isempty(file_name_cell)
fileout='metrics_stats';
else
fileout=file_name_cell{1};
end
% % *******************************************************************
%
% Determine which channels to output the difference of the metrics.
%
% diff chan is initially a row vector must be a column vector
accept_config=2;
diff_chan=[];
%
count=0;
prompt={'Select pairs of Channels', ' to Calculate a Difference',' in Metrics between the two channels'};
[buf, str]=pow10_round((1:num_chan), 0);
ColNames={'Channel Pair Number', 'Primary Channel', 'Minus Channel'};
out=[];
if isequal(flag, 2) || isequal(flag, 3)
while isequal(accept_config, 2) && logical(count < 3+(floor(num_chan/2))^2)
% Provide help for selecting the channels to calculate a difference
% in the metrics.
h3=helpdlg({'To add a pair of Channels to Calculate Differences in Metrics.', ...
'Add the Primary Channel then the Minus Channel.', '', ...
'The channels are paired together', 'Alternating Primary then Minus', ...
'The pairing of Channels is displayed in a Editable Table.'},'Channel Selection Help');
count=count+1;
[diff_chan_update, ok] = choosebox('Name', 'Channel Selection to Calculate a Difference', 'PromptString', prompt, ...
'SelectString','Ordered Pairs of Channels to Calculate Differences in Metrics:', ...
'SelectionMode', 'multiple', 'ChooseMode', 'copy', ...
'ListString', str, 'OKString', 'Finish and Update', 'ListSize', [300, 300]);
if ishandle(h3)
close(h3);
end
if length(diff_chan_update) >= 2
% The number of pairs must be even
num_new_pairs=floor(length(diff_chan_update)/2);
diff_chan=[diff_chan' diff_chan_update(1:(2*num_new_pairs))' ]';
end
if length(diff_chan) >= 2
[A2, A_str]=pow10_round(diff_chan', 0);
num_pairs=floor(length(A_str)/2);
t_cell=zeros(num_pairs, 3);
for e1=1:(num_pairs);
t_cell(e1,1)=e1;
t_cell(e1,2)=diff_chan(2*e1-1, 1);
t_cell(e1,3)=diff_chan(2*e1, 1);
end
if ishandle(out)
close(out);
end
out = tableGUI('FigName', 'Difference Channel Selection Table', ...
'array', t_cell, 'ColNames', ColNames, 'ColWidth', 180, ...
'RowHeight', 30, 'HorAlin', 'center', 'modal', '', 'position', 'center');
% Select to Accept or Modify Configuration
accept_config=menu('In the Table, are all of the pairings for channels present and correct?', 'Accept Configuration', 'Modify, Add, or Delete channels to Configuration' );
% Retrieve the channel difference configuration table.
hand=get(out, 'UserData');
data_new=zeros(num_pairs, 3);
row_list=[];
for e1=1:num_pairs;
for e2=1:3;
buf1=round(str2double(get(hand.hEdits(e1, e2), 'string')));
if (~isempty(buf1) && logical(buf1 >= 1)) && logical(buf1 <= num_chan)
data_new(e1, e2)=buf1;
else
row_list=[row_list e1];
end
end
end
buf2=setdiff(1:num_pairs, row_list);
diff_chan=zeros(2*length(buf2), 1);
for e1=1:length(buf2);
for e2=1:3;
buf1=round(str2double(get(hand.hEdits(buf2(e1), e2), 'string')));
if isequal(e2,2)
diff_chan(2*e1-1, 1)=buf1;
elseif isequal(e2,3)
diff_chan(2*e1, 1)=buf1;
end
end
end
if ishandle(out) && isequal(accept_config, 1)
close(out);
end
end
end
% Print the Configuration Table for the Last Time
[A2, A_str]=pow10_round(diff_chan', 0);
num_pairs=floor(length(A_str)/2);
t_cell=zeros(num_pairs, 3);
for e1=1:(num_pairs);
t_cell(e1,1)=e1;
t_cell(e1,2)=diff_chan(2*e1-1, 1);
t_cell(e1,3)=diff_chan(2*e1, 1);
end
h3=helpdlg({'Last Chance to Make sure the Channel Configuration is Correct', '', ...
'To add a pair of Channels to Calculate Differences in Metrics.', ...
'Add the Primary Channel then the Minus Channel.', '', ...
'The channels are paired together', 'Alternating Primary then Minus', ...
'The pairing of Channels is displayed in a Editable Table.'},...
'Channel Selection Help');
out = tableGUI('FigName', 'Difference Channel Selection Table', ...
'array', t_cell, 'ColNames', ColNames, 'ColWidth', 180, ...
'RowHeight', 30, 'HorAlin', 'center', 'modal', '', 'position', 'center');
% Retrieve the channel difference configuration table.
hand=get(out, 'UserData');
data_new=zeros(num_pairs, 3);
row_list=[];
for e1=1:num_pairs;
for e2=1:3;
buf1=round(str2double(get(hand.hEdits(e1, e2), 'string')));
if (~isempty(buf1) && logical(buf1 >= 1)) && logical(buf1 <= num_chan)
data_new(e1, e2)=buf1;
else
row_list=[row_list e1];
end
end
end
buf2=setdiff(1:num_pairs, row_list);
data_new=zeros(length(buf2), 3);
for e1=1:length(buf2);
for e2=1:3
buf1=round(str2double(get(hand.hEdits(e1, e2), 'string')));
if isequal(e2,2)
diff_chan(2*e1-1, 1)=buf1;
elseif isequal(e2,3)
diff_chan(2*e1, 1)=buf1;
end
end
end
if ishandle(out) && isequal(accept_config, 1)
close(out);
end
if ishandle(h3)
close(h3);
end
end
% % ********************************************************************
%
% Determine which descriptive statistics to print to a text file.
%
str{1}='1 Artihmetic Mean';
str{2}='2 Robust Mean';
str{3}='3 Standard Deviation';
str{4}='4 95% Confidence Interval';
str{5}='5 Median';
str{6}='6 Median Index';
str{7}='7 Minimum';
str{8}='8 Maximum';
prompt={'Which descriptive statistics of the metrics across impulses for each channel should be output to the file?', 'Select Desired descriptive statistics',' for printing to a text file.'};
[stat_to_get,ok] = listdlg('Name', 'Descriptive Statistics ', 'PromptString', prompt,'SelectionMode','multiple','ListString',str, 'InitialValue', [1,2,3,7,8], 'ListSize', [500, 500]);
if (isempty(stat_to_get) || any(logical(stat_to_get < 1))) || (any(logical(stat_to_get > 8)) || any(~isequal(ok, 1)))
stat_to_get=1;
end
prompt={'Which descriptive statistics of the metrics across files for each channel should be output to the file?', 'Select Desired descriptive statistics',' for printing to a text file.'};
[stat_to_get2,ok] = listdlg('Name', 'Descriptive Statistics ', 'PromptString', prompt,'SelectionMode','multiple','ListString',str, 'InitialValue', [1,2,3,7,8], 'ListSize', [500, 500]);
if (isempty(stat_to_get2) || any(logical(stat_to_get2 < 1))) || (any(logical(stat_to_get2 > 8)) || any(~isequal(ok, 1)))
stat_to_get2=1;
end
end
% ********************************************************************
%
% Run the Impulsive_Noise_Meter
%
[s, round_kind, round_digits]=Impulsive_Noise_Meter(filenamesin, fileout_txt, fileout_struct, save_struct, peak_interval, make_plot, save_plot, fig_format, Tool_Name, same_ylim, min_peak, sar, plot_str, Align_peaks, portrait_landscape, peak_alignment_tol, percent1, exhaust_cycle, sod );
% % ********************************************************************
% %
% % The output matlab data structures, snd and vibs were saved to
% % file names of the format
% %
% % For Sound Data fileout_txt '_snd.mat'
% %
% %
if isequal(flag2, 1)
% % ********************************************************************
%
% Calculate the difference or ratio between channels selected for
% difference calculations.
%
ratio_metrics=[3, 4, 5, 20];
if ~isempty(diff_chan)
[s]=calc_diff_metrics(s, diff_chan, ratio_metrics, round_kind, round_digits);
end
if save_struct == 1
save(fileout_struct, 's');
end
% ********************************************************************
%
% Run the make_table_compare_systems
%
make_summary_impls_stats_table(s, stat_to_get, stat_to_get2, fileout, flag, ratio_metrics, round_kind, round_digits);
end
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -