classdef acoustic_analysis < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        UIFigure                matlab.ui.Figure
        FeaturestatisticsLabel  matlab.ui.control.Label
        FeatureanalysisButton   matlab.ui.control.Button
        UITable                 matlab.ui.control.Table
        UIAxes2_12              matlab.ui.control.UIAxes
        UIAxes2_11              matlab.ui.control.UIAxes
        UIAxes2_10              matlab.ui.control.UIAxes
        UIAxes2_9               matlab.ui.control.UIAxes
        UIAxes2_8               matlab.ui.control.UIAxes
        UIAxes2_7               matlab.ui.control.UIAxes
        UIAxes2_6               matlab.ui.control.UIAxes
        UIAxes2_5               matlab.ui.control.UIAxes
        UIAxes2_4               matlab.ui.control.UIAxes
        UIAxes2_3               matlab.ui.control.UIAxes
        UIAxes2_2               matlab.ui.control.UIAxes
        UIAxes2                 matlab.ui.control.UIAxes
        UIAxes                  matlab.ui.control.UIAxes
    end

    
    properties (Access = public)
        exc % Description
    end
    

    % Callbacks that handle component events
    methods (Access = private)

        % Code that executes after component creation
        function startupFcn(app, edge)
            app.exc = edge;
        end

        % Button pushed function: FeatureanalysisButton
        function FeatureanalysisButtonPushed(app, event)
            load dataimgaco.mat
            
            if app.exc == 1
            aa1 = a1';
            ra=reshape(aa1,1,[]);
            showaco = a1;
            
            elseif app.exc == 2
            aa2 = a2';
            ra=reshape(aa2,1,[]);
            showaco = a2;
            
            elseif app.exc == 3
            aa3 = a3';
            ra=reshape(aa3,1,[]);
            showaco = a3;
            
            end
            
            featureNamesCell = {'max','min','mean','med','peak','arv','var','std','kurtosis',...
               'skewness','rms','rs','rmsa','waveformF','peakF','impulseF','clearanceF',...
               'FC','MSF','RMSF','VF','RVF',...
               'SKMean','SKStd','SKSkewness','SKKurtosis'};
            
            fea = genFeatureTF(showaco,48000,featureNamesCell);
            
            plot(app.UIAxes2,fea(:,3)); %平均值 mean
            plot(app.UIAxes2_2,fea(:,5)); %峰值 peak
            plot(app.UIAxes2_3,fea(:,6)); %整流平均值 arv
            plot(app.UIAxes2_4,fea(:,7)); %方差 var
            plot(app.UIAxes2_5,fea(:,8)); %标准差 std
            plot(app.UIAxes2_6,fea(:,14)); %波形因子 waveformF
            plot(app.UIAxes2_7,fea(:,16)); %脉冲因子 impulseF
            plot(app.UIAxes2_8,fea(:,18)); %重心频率 FC
            plot(app.UIAxes2_9,fea(:,20)); % 均方根频率 RMSF
            plot(app.UIAxes2_10,fea(:,21)); % 频率方差 VF
            plot(app.UIAxes2_11,fea(:,23)); %谱峭度 SKMean
            plot(app.UIAxes2_12,fea(:,17)); %裕度因子 clearanceF
            
            plot(app.UIAxes,ra);
            
            app.UITable.ColumnName = featureNamesCell;
            app.UITable.Data = fea;
        end
    end

    % Component initialization
    methods (Access = private)

        % Create UIFigure and components
        function createComponents(app)

            % Create UIFigure and hide until all components are created
            app.UIFigure = uifigure('Visible', 'off');
            app.UIFigure.Position = [100 100 720 510];
            app.UIFigure.Name = 'MATLAB App';

            % Create UIAxes
            app.UIAxes = uiaxes(app.UIFigure);
            title(app.UIAxes, 'Filtered signal')
            zlabel(app.UIAxes, 'Z')
            app.UIAxes.XTick = [];
            app.UIAxes.YTick = [];
            app.UIAxes.FontSize = 14;
            app.UIAxes.Position = [1 366 477 145];

            % Create UIAxes2
            app.UIAxes2 = uiaxes(app.UIFigure);
            title(app.UIAxes2, 'Mean')
            zlabel(app.UIAxes2, 'Z')
            app.UIAxes2.XTick = [];
            app.UIAxes2.YTick = [];
            app.UIAxes2.Position = [1 247 120 120];

            % Create UIAxes2_2
            app.UIAxes2_2 = uiaxes(app.UIFigure);
            title(app.UIAxes2_2, 'Peak')
            zlabel(app.UIAxes2_2, 'Z')
            app.UIAxes2_2.XTick = [];
            app.UIAxes2_2.YTick = [];
            app.UIAxes2_2.Position = [120 246 120 120];

            % Create UIAxes2_3
            app.UIAxes2_3 = uiaxes(app.UIFigure);
            title(app.UIAxes2_3, 'Rectified average')
            zlabel(app.UIAxes2_3, 'Z')
            app.UIAxes2_3.XTick = [];
            app.UIAxes2_3.YTick = [];
            app.UIAxes2_3.Position = [239 246 120 120];

            % Create UIAxes2_4
            app.UIAxes2_4 = uiaxes(app.UIFigure);
            title(app.UIAxes2_4, 'variance ')
            zlabel(app.UIAxes2_4, 'Z')
            app.UIAxes2_4.XTick = [];
            app.UIAxes2_4.YTick = [];
            app.UIAxes2_4.Position = [358 247 120 120];

            % Create UIAxes2_5
            app.UIAxes2_5 = uiaxes(app.UIFigure);
            title(app.UIAxes2_5, 'standard deviation')
            zlabel(app.UIAxes2_5, 'Z')
            app.UIAxes2_5.XTick = [];
            app.UIAxes2_5.YTick = [];
            app.UIAxes2_5.Position = [1 127 120 120];

            % Create UIAxes2_6
            app.UIAxes2_6 = uiaxes(app.UIFigure);
            title(app.UIAxes2_6, 'waveform factor')
            zlabel(app.UIAxes2_6, 'Z')
            app.UIAxes2_6.XTick = [];
            app.UIAxes2_6.YTick = [];
            app.UIAxes2_6.Position = [120 126 120 120];

            % Create UIAxes2_7
            app.UIAxes2_7 = uiaxes(app.UIFigure);
            title(app.UIAxes2_7, 'impulse factor')
            zlabel(app.UIAxes2_7, 'Z')
            app.UIAxes2_7.XTick = [];
            app.UIAxes2_7.YTick = [];
            app.UIAxes2_7.Position = [239 126 120 120];

            % Create UIAxes2_8
            app.UIAxes2_8 = uiaxes(app.UIFigure);
            title(app.UIAxes2_8, 'gravity frequency')
            zlabel(app.UIAxes2_8, 'Z')
            app.UIAxes2_8.XTick = [];
            app.UIAxes2_8.YTick = [];
            app.UIAxes2_8.Position = [358 127 120 120];

            % Create UIAxes2_9
            app.UIAxes2_9 = uiaxes(app.UIFigure);
            title(app.UIAxes2_9, 'mean square frequency')
            zlabel(app.UIAxes2_9, 'Z')
            app.UIAxes2_9.XTick = [];
            app.UIAxes2_9.YTick = [];
            app.UIAxes2_9.Position = [1 8 120 120];

            % Create UIAxes2_10
            app.UIAxes2_10 = uiaxes(app.UIFigure);
            title(app.UIAxes2_10, 'frequency variance')
            zlabel(app.UIAxes2_10, 'Z')
            app.UIAxes2_10.XTick = [];
            app.UIAxes2_10.YTick = [];
            app.UIAxes2_10.Position = [120 7 120 120];

            % Create UIAxes2_11
            app.UIAxes2_11 = uiaxes(app.UIFigure);
            title(app.UIAxes2_11, 'Mean value of spectral cliffs')
            zlabel(app.UIAxes2_11, 'Z')
            app.UIAxes2_11.XTick = [];
            app.UIAxes2_11.YTick = [];
            app.UIAxes2_11.Position = [239 7 120 120];

            % Create UIAxes2_12
            app.UIAxes2_12 = uiaxes(app.UIFigure);
            title(app.UIAxes2_12, 'clearance factor')
            zlabel(app.UIAxes2_12, 'Z')
            app.UIAxes2_12.XTick = [];
            app.UIAxes2_12.YTick = [];
            app.UIAxes2_12.Position = [358 8 120 120];

            % Create UITable
            app.UITable = uitable(app.UIFigure);
            app.UITable.ColumnName = '';
            app.UITable.RowName = {'''max'',''min'',''mean'',''med'',''peak'',''arv'',''var'',''std'',''kurtosis'',...'; '               ''skewness'',''rms'',''rs'',''rmsa'',''waveformF'',''peakF'',''impulseF'',''clearanceF'',...'; '               ''FC'',''MSF'',''RMSF'',''VF'',''RVF'',...'; '               ''SKMean'',''SKStd'',''SKSkewness'',''SKKurtosis'''};
            app.UITable.Position = [485 136 227 335];

            % Create FeatureanalysisButton
            app.FeatureanalysisButton = uibutton(app.UIFigure, 'push');
            app.FeatureanalysisButton.ButtonPushedFcn = createCallbackFcn(app, @FeatureanalysisButtonPushed, true);
            app.FeatureanalysisButton.FontSize = 16;
            app.FeatureanalysisButton.Position = [508 26 180 60];
            app.FeatureanalysisButton.Text = 'Feature analysis';

            % Create FeaturestatisticsLabel
            app.FeaturestatisticsLabel = uilabel(app.UIFigure);
            app.FeaturestatisticsLabel.FontSize = 14;
            app.FeaturestatisticsLabel.Position = [543 470 111 22];
            app.FeaturestatisticsLabel.Text = 'Feature statistics';

            % Show the figure after all components are created
            app.UIFigure.Visible = 'on';
        end
    end

    % App creation and deletion
    methods (Access = public)

        % Construct app
        function app = acoustic_analysis(varargin)

            % Create UIFigure and components
            createComponents(app)

            % Register the app with App Designer
            registerApp(app, app.UIFigure)

            % Execute the startup function
            runStartupFcn(app, @(app)startupFcn(app, varargin{:}))

            if nargout == 0
                clear app
            end
        end

        % Code that executes before app deletion
        function delete(app)

            % Delete UIFigure when app is deleted
            delete(app.UIFigure)
        end
    end
end