📄 make_summary_impls_stats_table.m
字号:
function make_summary_impls_stats_table(s, stat_to_get, stat_to_get2, fileout, flag, ratio_metrics, round_kind, round_digits)
% % make_summary_impls_stats_table: Makes a summary table of the output of the Impulsive_Noise_Meter; Impulse, Impulsive, Noise, Sound, Meter
% %
% % Syntax:
% %
% % make_summary_impls_stats_table(s, stat_to_get, stat_to_get2, fileout, flag, ratio_metrics, round_kind, round_digits);
% %
% % *****************************************************************
% %
% % Description:
% %
% % This program takes the output from the Impulsive_Noise_Meter and
% % calc_channel_diff prorgams and prints a summary of the descriptive
% % statistics of the metrics to a table. Also a summary of the statistics
% % across channels and overall statistic across files is printed.
% %
% % The Table has a format described by the summary pattern below
% %
% % Label stat_to_get(1) (Arithmetic Mean, Robust Mean , etc)
% %
% % Metric 1 Metric 1 ...
% % var 1 var 2 ...var n var 1 var 2 ...var n ...
% % File 1
% % channel 1 d1 d2 dn d1 d2 dn
% % channel ... ...
% % channel m
% %
% % ...
% %
% % File x
% % channel 1 d1 d2 dn d1 d2 dn
% % channel ... ...
% % channel m
% %
% %
% % Summary Across Channels var 1 var 2 ...var n var 1 var 2 ...var n
% % stat_to_get2(1)
% % File 1 d1 d2 dn d1 d2 dn
% % ... ...
% % File x
% %
% % ...
% %
% % stat_to_get2(xx)
% % File 1 d1 d2 dn d1 d2 dn
% % ... ...
% % File x
% %
% %
% % Summary Across Files var 1 var 2 ...var n
% % stat_to_get2(1)
% % File 1 d1 d2 dn d1 d2 dn
% % ... ...
% % File x
% %
% % ...
% %
% % stat_to_get2(xx)
% % File 1 d1 d2 dn d1 d2 dn
% % ... ...
% % File x
% %
% %
% % ...
% %
% %
% % Label stat_to_get(2) (Arithmetic Mean, Robust MEan , etc)
% %
% % Metric 1 Metric 1 ...
% % var 1 var 2 ...var n var 1 var 2 ...var n ...
% % File 1
% % channel 1 d1 d2 dn d1 d2 dn
% % channel ... ...
% % channel m
% %
% % ...
% %
% % File x
% % channel 1 d1 d2 dn d1 d2 dn
% % channel ... ...
% % channel m
% %
% %
% % Summary Across Channels var 1 var 2 ...var n var 1 var 2 ...var n
% % stat_to_get2(1)
% % File 1 d1 d2 dn d1 d2 dn
% % ... ...
% % File x
% %
% % ...
% %
% % stat_to_get2(xx)
% % File 1 d1 d2 dn d1 d2 dn
% % ... ...
% % File x
% %
% %
% % Summary Across Files var 1 var 2 ...var n
% % stat_to_get2(1)
% % File 1 d1 d2 dn d1 d2 dn
% % ... ...
% % File x
% %
% % ...
% %
% % stat_to_get2(xx)
% % File 1 d1 d2 dn d1 d2 dn
% % ... ...
% % File x
% %
% %
% %
% %
% % The input and output variables are described below.
% %
% % *****************************************************************
% %
% % Input Variables
% %
% % s={}; load shock_tube; % is the data structure created using the
% % % Impulsive_Noise_Meter.
% % % default is load shock_tube. Runs a demo table.
% %
% % stat_to_get=1:8; % is a vector or constant stipulating which
% % % descriptive statistics to display in the
% % % table summarizing the metrics across the
% % % impulses in a single file.
% % % default is stat_to_get2=1:8; all statistics
% %
% % Any combination of the following stats can be displayed by placing the
% % index of the stat in the array stat_to_get in any desired order.
% %
% % % stat_to_get=1; % Arithmetic Mean
% % % stat_to_get=2; % Robust Mean
% % % stat_to_get=3; % Standard Deviation
% % % stat_to_get=4; % 95% Confidence Interval
% % % stat_to_get=5; % Median
% % % stat_to_get=6; % Median Index
% % % stat_to_get=7; % Minimum
% % % stat_to_get=8; % Maximum
% %
% % stat_to_get2=1:8; % is a vector or constant stipulating which
% % % descriptive statistics to display in the
% % % table summarizing the metrics across the files.
% % % These are called the overall values.
% % % default is stat_to_get2=1:8; all statistics
% %
% % fileout='Output_file_name.txt';
% % % fileout is the filenmae of the output file.
% % % The extension '.txt' is automatically added.
% %
% % flag=1; print absolute stats only
% % flag=2; print difference stats only
% % flag=3; print both absolute and difference stats
% %
% % % if flag does not equal 1, 2, or 3 then print
% % % both absolute and difference stats.
% %
% % ratio_metrics=[3, 4, 5, 20]; % is an array of indices of metrics for
% % % the diff_chans array that are
% % % calculated as ratios instead of
% % % differences
% %
% % round_kind=1; % Array of values one element for the rta array
% % % and one element for each varargin array
% % % (see example)
% % % 1 round to specified number of significant
% % % digits
% % %
% % % 0 round to specified digits place
% % %
% % % default is round_kind=1;
% %
% % round_digits=3; % Array of values one element for the rta array
% % % and one element for each varargin array
% % % (see example)% Type of rounding depends on round_kind
% % %
% % % if round_kind==1 number of significant digits
% % % if round_kind==0 specified digits place
% % %
% % % default is round_digits=3;
% %
% % *****************************************************************
%
%
% Example='1';
%
% % This is an example using shock tube data! The data compares two
% % data acquisition rates.
%
% % An example which outputs the mean of the metrics.
%
% load shock_tube;
% stat_to_get=1;
% stat_to_get2=1;
% fileout='Compare_data_acquisition_sytems';
% flag=1;
% make_summary_impls_stats_table(s, stat_to_get, stat_to_get2, fileout, flag);
%
%
% % Example='2';
%
% % An example which outputs all of the metrics.
%
% load shock_tube;
% stat_to_get=[1:8]; % return all of the stats, from Arithmetic mean
% % to maximum!
% stat_to_get2=[1:8]; % return all of the stats, from Arithmetic mean
% % to maximum!
%
% fileout='Compare_data_acquisition_sytems2';
% flag=3;
% make_summary_impls_stats_table(s, stat_to_get, stat_to_get2, fileout, flag);
%
%
% % *****************************************************************
% %
% %
% % Subprograms
% %
% %
% %
% % List of Dependent Subprograms for
% % make_summary_impls_stats_table
% %
% %
% % Program Name Author FEX ID#
% % 1) file_extension
% % 2) genHyper Ben Barrowes 6218
% % 3) LMSloc Alexandros Leontitsis 801
% % 4) m_round
% % 5) num_impulsive_samples
% % 6) pow10_round
% % 7) print_channel_stats
% % 8) print_overall_stats
% % 9) sd_round
% % 10) splat_cell
% % 11) t_alpha
% % 12) t_confidence_interval
% % 13) t_icpbf
% %
% %
% %
% % *****************************************************************
% %
% % Written by Edward L. Zechmann
% %
% % date 6 August 2008
% %
% % modified 9 August 2008 Vectrorized stat_to_get.
% % Updated comments.
% %
% % modified 10 August 2008 Updated comments.
% %
% % modified 1 September 2008 Added print_channel_stats and
% % print_overall_stats to the program
% % which greatly improved its
% % usefulness.
% %
% % modified 10 September 2008 Updated comments.
% %
% % modified 10 December 2008 Updated comments.
% %
% % modified 7 January 2009 Updated comments.
% %
% % modified 19 January 2009 Updated to include rounding.
% %
% %
% % *****************************************************************
% %
% % Please feel free to modify this code.
% %
% % See Also: Main_Sound, Impulsive_Noise_Meter, Main_sound_and_vibs, Continuous_Sound_and_Vibrations_Analysis
% %
if (nargin < 1 || isempty(s)) || ~iscell(s)
s={};
load shock_tube;
end
if (nargin < 2 || isempty(stat_to_get)) || ~isnumeric(stat_to_get)
stat_to_get=[1:8];
end
if (nargin < 3 || isempty(stat_to_get2)) || ~isnumeric(stat_to_get2)
stat_to_get2=[1:8];
end
if (nargin < 4 || isempty(fileout)) || ~ischar(fileout)
fileout='Output_file_name.txt';
end
if (nargin < 5 || isempty(flag)) || ~isnumeric(flag)
flag=3;
end
if (nargin < 6 || isempty(ratio_metrics)) || ~isnumeric(ratio_metrics)
ratio_metrics=[3, 4, 5];
end
if (nargin < 7 || isempty(round_kind)) || ~isnumeric(round_kind)
round_kind=1;
end
if (nargin < 8 || isempty(round_digits)) || ~isnumeric(round_digits)
round_digits=3;
end
[num_files, num_vars]=size(s);
num_channels_array=zeros(num_files,1);
num_stats=length(stat_to_get);
sum_num_channels_a=zeros(num_files, num_vars);
num_channels_a=zeros(num_files, num_vars);
num_diff_channels_a=zeros(num_files, num_vars);
[num_samples_ca]=num_impulsive_samples(s);
% Determine the size of the concatenated metrics table
for e1=1:num_files; % Data files
num_channels=[];
% Number of Variables (Number of Data Acquisition Systems)
for e3=1:num_vars;
if ~isempty(s{e1,e3})
num_channels=0;
num_stats2=0;
if isfield(s{e1,e3}, 'stats_of_metrics')
[num_metrics, num_channels, num_stats2]=size(s{e1,e3}.stats_of_metrics);
end
num_diff_channels=0;
num_diff_stats2=0;
if isfield(s{e1,e3}, 'diff_stats_of_metrics')
[num_metrics, num_diff_channels, num_diff_stats2]=size(s{e1,e3}.diff_stats_of_metrics);
end
if num_channels >= 1 || logical(num_diff_channels >= 1)
switch flag
case 1
num_channels_a(e1, e3)=num_channels;
num_diff_channels_a(e1, e3)=0;
sum_num_channels_a(e1, e3)=num_channels;
num_channels_array(e1)=max([num_channels, num_channels_array(e1)]);
case 2
num_channels_a(e1, e3)=0;
num_diff_channels_a(e1, e3)=num_diff_channels;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -