⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 data_outliers3.m

📁 我认为很不错的语音处理的matlab源代码
💻 M
📖 第 1 页 / 共 4 页
字号:

% Write Data Vertically
if isequal(save_file, 1)

    % check if outfile is a filename or a fid
    if isa(outfile, 'double') && outfile > -1
        flag2=1;
        fid=outfile;
    else
        flag2=0;
        [filename_base, ext]=file_extension(outfile);
        fid=fopen([filename_base '.txt'], 'w');
    end

    for e2=1:(1+num_vars);

        if isequal(e2, 1)
            rta=rta2;
            [num_data_rows, buf]=size(rta);

            mn_rt1a=rt_stats(:, 1);
            mn_rt2a=rt_stats(:, 2);
            stdrta=rt_stats(:, 3);
            ci_inta=rt_stats(:, 4);
            median_indexa=rt_stats(:, 5);
            median_val=rt_stats(:, 6);
            min_rta=rt_stats(:, 7);
            max_rta=rt_stats(:, 8);

            out_mn_rt1a=rt_outlier_stats(:, 1);
            out_mn_rt2a=rt_outlier_stats(:, 2);
            out_stdrta=rt_outlier_stats(:, 3);
            out_ci_inta=rt_outlier_stats(:, 4);
            out_median_indexa=rt_outlier_stats(:, 5);
            out_median_val=rt_outlier_stats(:, 6);
            out_min_rta=rt_outlier_stats(:, 7);
            out_max_rta=rt_outlier_stats(:, 8);

        else
            rta=varargin{e2-1};
            [num_data_rows, buf]=size(rta);
            for e1=1:num_data_rows;
                mn_rt1a(e1, 1)=other_stats(e2-1, e1, 1);
                mn_rt2a(e1, 1)=other_stats(e2-1, e1, 2);
                stdrta(e1, 1)=other_stats(e2-1, e1, 3);
                ci_inta(e1, 1)=other_stats(e2-1, e1, 4);
                median_indexa(e1, 1)=other_stats(e2-1, e1, 5);
                median_val(e1, 1)=other_stats(e2-1, e1, 6);
                min_rta(e1, 1)=other_stats(e2-1, e1, 7);
                max_rta(e1, 1)=other_stats(e2-1, e1, 8);
            end

            for e1=1:num_data_rows;
                out_mn_rt1a(e1, 1)=other_outlier_stats(e2-1, e1, 1);
                out_mn_rt2a(e1, 1)=other_outlier_stats(e2-1, e1, 2);
                out_stdrta(e1, 1)=other_outlier_stats(e2-1, e1, 3);
                out_ci_inta(e1, 1)=other_outlier_stats(e2-1, e1, 4);
                out_median_indexa(e1, 1)=other_outlier_stats(e2-1, e1, 5);
                out_median_val(e1, 1)=other_outlier_stats(e2-1, e1, 6);
                out_min_rta(e1, 1)=other_outlier_stats(e2-1, e1, 7);
                out_max_rta(e1, 1)=other_outlier_stats(e2-1, e1, 8);
            end

        end


        %Print the row header for each data set;
        if isequal(e2, 1)
            fprintf(fid, 'Data and Descriptive Statistics of Main Data Set to determine Outliers\r\n\r\n');


            fprintf(fid, 'Array and Row Names\tData\t');

            tabs1='';
            for e1=1:(max_num_cols);
                tabs1=[tabs1, '\t'];
            end
            fprintf(fid, tabs1);


            if ~isequal(sod, 1) && logical(max_num_out > 0)
                fprintf(fid, 'Descriptive Statistics of Data with Outliers Removed\t');
                tabs1='';
                for e1=1:(num_stats);
                    tabs1=[tabs1, '\t'];
                end
                fprintf(fid, tabs1);
                fprintf(fid,'Analysis of Outliers');

                tabs1='';
                for e1=1:(max_num_out+1);
                    tabs1=[tabs1, '\t'];
                end
                fprintf(fid, tabs1);

                fprintf(fid, 'Descriptive Statistics of Outliers');

            else
                fprintf(fid, 'Descriptive Statistics of Data ');
            end

            fprintf(fid, '\r\n\r\n\t');

        elseif isequal(e2, 2)
            fprintf(fid, 'Other Data and Statistics\t');
        else
            fprintf(fid, '\t');
        end

        if isequal(e2, 1)
            fprintf(fid, '%s\t', col_name);
            tabs1='';
            for e1=1:(max_num_cols-1);
                tabs1=[tabs1, '\t'];
            end
        else
            tabs1='';
            for e1=1:(max_num_cols);
                tabs1=[tabs1, '\t'];
            end
        end

        fprintf(fid, tabs1);

        if num_cols  > 2
            fprintf(fid, '\tArithmetic Mean\tRobust Mean\tStandard Deviation\t95+-%%Confidence Interval\tMedian Index\tMedian\tMinimum\tMaximum');


            % If there are outliers then print all of the descriptive
            % statistics of the outliers.
            if max_num_out > 0
                fprintf(fid,'\t\tOutliers');
                tabs1='';
                for e3=1:(max_num_out);
                    tabs1=[tabs1, '\t'];
                end

                fprintf(fid, tabs1);
                fprintf(fid, '\tArithmetic Mean\tRobust Mean\tStandard Deviation\t95+-%%Confidence Interval\tMedian Index\tMedian\tMinimum\tMaximum\t\r\n');
            else
                fprintf(fid, '\r\n');
            end
        else
            fprintf(fid, '\tArithmetic Mean\tRobust Mean\t\r\n');
        end

        fprintf(fid, '%s\t', [array_names{e2}, ' ', array_units{e2} ]);

        nums=1:(max_num_cols);
        fprintf(fid, '%i\t', nums);
        if e2 > length(array_units)
            e3=length(array_units);
        else
            e3=e2;
        end


        if max_num_cols  > 2
            % Print the units of the descriptive statistics
            % they have the same units as the array; however, the median
            % index has the units of an index of the median of the data array.
            fprintf(fid, '\t');
            for e1=1:4;
                fprintf(fid, [array_units{e3}, '\t']);
            end

            fprintf(fid, '%s\t', 'Index');

            for e1=6:num_stats;
                fprintf(fid, [array_units{e3}, '\t']);
            end


            if max_num_out > 0

                fprintf(fid, '\t%s\t', 'Indices');

                tabs1='';
                for e1=1:(max_num_out);
                    tabs1=[tabs1, '\t'];
                end
                fprintf(fid, tabs1);

                % Print the units of the descriptive statistics
                % they have the same unitsas the array; however, the median
                % index has the units of an index.
                for e1=1:4;
                    fprintf(fid, [array_units{e3}, '\t']);
                end

                fprintf(fid, '%s\t', 'Index');

                for e1=6:num_stats;
                    fprintf(fid, [array_units{e3}, '\t']);
                end

            end

            fprintf(fid, '\r\n');

        else
            fprintf(fid, ['\t' array_units{e3}, '\t', array_units{e3}, '\t\r\n']);
        end

        [num_data_rows, buf]=size(rta);

        for e1=1:num_data_rows;

            if iscell(rta);
                buf1=rta{e1, :};
                if iscell(buf1);
                    rt=buf1{1};
                else
                    rt=buf1;
                end
            else
                rt=rta(e1, :);
            end

            num_cols=length(rt);

            [mp1 np1]=size(ptsa);

            if mp1 < e1
                pts=ptsa{1,e2};
                npts=nptsa{1,e2};
            else
                pts=ptsa{e1,e2};
                npts=nptsa{e1, e2};
            end

            mn_rt1=mn_rt1a(e1);
            mn_rt2=mn_rt2a(e1);
            std_rt=stdrta(e1);
            ci_int=ci_inta(e1);
            ix=median_indexa(e1);
            medianrt=median_val(e1);
            minrt=min_rta(e1);
            maxrt=max_rta(e1);

            out_mn_rt1=out_mn_rt1a(e1);
            out_mn_rt2=out_mn_rt2a(e1);
            out_std_rt=out_stdrta(e1);
            out_ci_int=out_ci_inta(e1);
            out_ix=out_median_indexa(e1);
            out_medianrt=out_median_val(e1);
            out_minrt=out_min_rta(e1);
            out_maxrt=out_max_rta(e1);


            if ~isempty(row_unit)
                if iscell(row_unit)
                    if ischar(row_unit{e1})
                        row_unit1=row_unit{e1};
                    else
                        % If its not a string assume its a number
                        row_unit1=num2str(row_unit{e1});
                    end
                elseif ischar(row_unit)
                    row_unit1=row_unit;
                else
                    row_unit1=num2str(row_unit(e1));
                end
            else
                row_unit1='';
            end

            if isempty(row_names)
                fprintf(fid, '%i\t', e1);
            else
                if length(row_names) >= e1
                    if iscell(row_names)
                        if ischar(row_names{e1})
                            if isempty(row_names{e1})
                                fprintf(fid, '%s\t', [num2str(e1), ' ', row_unit1]);
                            else
                                fprintf(fid, '%s\t', [row_names{e1}, ' ', row_unit1]);
                            end
                        else
                            % If its not a string assume its a number
                            if isempty(num2str(row_names{e1}))
                                fprintf(fid, '%s\t', [num2str(e1), ' ', row_unit1]);
                            else
                                fprintf(fid, '%s\t', [num2str(row_names{e1}), ' ', row_unit1]);
                            end
                        end
                    else
                        if isempty(num2str(row_names(e1)))
                            fprintf(fid, '%s\t', [num2str(e1), ' ', row_unit1]);
                        else
                            if ischar(row_names(e1))
                                fprintf(fid, '%s\t', [row_names ' ', row_unit1]);
                            else
                                fprintf(fid, '%s\t', [num2str(row_names(e1)), ' ', row_unit1]);
                            end
                        end
                    end
                else
                    fprintf(fid, '%i\t', e1);
                end
            end


            % Print the Data
            [A2, A_str]=m_round(rt, round_kind(e2), round_digits(e2));


            for e3=1:length(A_str);
                fprintf(fid, '%s\t', A_str{e3});
            end

            if max_num_cols > num_cols
                for e3=1:(max_num_cols-num_cols);
                    fprintf(fid, '\t' );
                end
            end



            if num_cols  > 2

                % Print the Descriptive Statistics of all the data
                [A2, A_str]=m_round([mn_rt1 mn_rt2 std_rt, ci_int ix medianrt minrt maxrt], [round_kind(e2)*[1 1] [1 1 0] round_kind(e2)*[1 1 1]], [round_digits(e2)*[1 1] [3 3 0] round_digits(e2)*[1 1 1]]);
                
                fprintf(fid, '\t' );
                for e3=1:length(A_str);
                    fprintf(fid, '%s\t', A_str{e3});
                end

                fprintf(fid, '\t' );
                for e3=1:length(npts);
                    fprintf(fid, '%d\t', npts(e3) );
                end


                if max_num_out > 0

                    fprintf(fid, '\t' );
                    for e3=1:(max_num_out-length(npts));
                        fprintf(fid, '\t' );
                    end

                    % Print the Descriptive Statistics of the outlier data
                    [A2, A_str]=m_round([out_mn_rt1 out_mn_rt2 out_std_rt, out_ci_int out_ix out_medianrt out_minrt out_maxrt], [round_kind(e2)*[1 1] [1 1 0] round_kind(e2)*[1 1 1]], [round_digits(e2)*[1 1] [3 3 0] round_digits(e2)*[1 1 1]]);
                

                    for e3=1:length(A_str);
                        fprintf(fid, '%s\t', A_str{e3});
                    end

                end

            else

                % Print the Descriptive Statistics of all the data
                [A2, A_str]=m_round([mn_rt1, mn_rt2], round_kind(e2), round_digits(e2));

                fprintf(fid, '\t' );
                for e3=1:length(A_str);
                    fprintf(fid, '%s\t', A_str{e3});
                end

            end

            fprintf(fid, '\r\n');

        end
        fprintf(fid, '\r\n');
    end

    if isequal(flag2, 0)
        fclose(fid);
        fclose('all');
    end

end

if isequal(sod, 1) || logical(max_num_out < 1) || logical(max_num_cols < 2)
    rt_outlier_stats=[];
    other_outlier_stats=[];
end

% Write Data Horizontally

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -