【数字信号处理】基于Matlab Designer制作的信号生成、叠加与检测器

下载链接(CSDN)
下载链接(百度网盘)

软件的界面如下:
在这里插入图片描述
主要分为了三个控制区模块,即信号生成预览区,信号观测区以及信号分析区。在信号生成区可以通过键盘输入或是滑块调节的方式改变输入信号的频率、赋值以及初相,信号生成区的预览窗口可以实时的动态调整当前信号的波形展示。此外目前设计了白噪声、正弦波、方波以及正弦波四种类型的信号输入。
完成输入参数的调节后,点击“ADD”按钮,就可以将当前的信号送入信号观测区,当ADD进入了多个信号通道后,就可以观测到多信号叠加后的输出波形。点击“Run”可以动态观测叠加波形的运动。点击“Play”可以播放当前叠加波的声音,持续一秒钟时间。点击“Clear”,就可以清空当前信号观测区的信号输入。
最后,在信号分析区,设计了针对叠加信号的频域图以及其他参数的分析功能,具体如界面所示。
如无法下载,源码如下

classdef Digital_signal_generation_and_analyzer_exported < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        UIFigure                matlab.ui.Figure
        SignalAnalysis          matlab.ui.container.Panel
        STD_error               matlab.ui.control.NumericEditField
        Label_9                 matlab.ui.control.Label
        DigitalSignalGenerationandAnalyzerLabel  matlab.ui.control.Label
        PoweredbyVulcan_QLabel  matlab.ui.control.Label
        Analysis                matlab.ui.control.Button
        Mean                    matlab.ui.control.NumericEditField
        Label_8                 matlab.ui.control.Label
        RMS                     matlab.ui.control.NumericEditField
        Label_7                 matlab.ui.control.Label
        Peak_Grain              matlab.ui.control.NumericEditField
        Label_6                 matlab.ui.control.Label
        Grain                   matlab.ui.control.NumericEditField
        Label_5                 matlab.ui.control.Label
        Peak                    matlab.ui.control.NumericEditField
        Label_3                 matlab.ui.control.Label
        UIAxes                  matlab.ui.control.UIAxes
        SignalObservation       matlab.ui.container.Panel
        ClearObservation        matlab.ui.control.Button
        PlayObservation         matlab.ui.control.Button
        StopObservation         matlab.ui.control.Button
        RunObservation          matlab.ui.control.Button
        SignalObservation_axis  matlab.ui.control.UIAxes
        SignalGenerated         matlab.ui.container.Panel
        TextPhase               matlab.ui.control.TextArea
        radLabel                matlab.ui.control.Label
        PhaseSlider             matlab.ui.control.Slider
        AddSignal               matlab.ui.control.Button
        TextAmplitude           matlab.ui.control.TextArea
        Label_2                 matlab.ui.control.Label
        TextFrequency           matlab.ui.control.TextArea
        Label                   matlab.ui.control.Label
        AmplitudeSlider         matlab.ui.control.Slider
        FrequencySlider         matlab.ui.control.Slider
        SignalTypes             matlab.ui.container.ButtonGroup
        SquareWave              matlab.ui.control.RadioButton
        TriangularWave          matlab.ui.control.RadioButton
        SineWave                matlab.ui.control.RadioButton
        WhiteNoise              matlab.ui.control.RadioButton
        SignalPreview_axis      matlab.ui.control.UIAxes
    end


    properties (Access = private)
        FrequencyGenerate  % 信号生成窗口的信号频率(600为初始值)
        AmplitudeGenerate  % 信号生成窗口的信号幅值(0.5为初始值)
        PhaseGenerate % 信号生成窗口的信号相位
        Timer_Generate % 信号生成窗口的定时器,用于预览输入信号
        Phase_generate  % 信号生成窗口绘制函数运行相位
        Phase_generate_step  % 一次计时中断预览窗口的变化步长
        Fs  %采样频率
        N_observation %生成区采样长度
        N_Generate  %观测区采样长度
        Timer_View % 信号观测窗口的定时器,用于大屏输出观测信号
        InformationStorage = []; %频率,赋值,相位,类型
        InformationPlot = []; % Description
        Phase_observation = 0;
        Phase_observation_step = 0.1 * pi;
        observation_flag = 0; %默认关闭observation
        generate_flag = 1; %默认打开generate
    end

    methods (Access = private)

        function value = cell2double(~,value)
            value = cell2mat(value);
            value = str2double(value);
        end

        function  TimerInit_G(app)
            app.Timer_Generate = timer;
            app.Timer_Generate.StartDelay = 0;
            app.Timer_Generate.Period = 0.05 ; %定时器定时中断周期
            app.Timer_Generate.ExecutionMode = 'fixedDelay';
            app.Timer_Generate.TimerFcn = @(~,~)TimerGenerate_handler(app);
            start(app.Timer_Generate);
        end
        function TimerInit_O(app)
            app.Timer_View = timer;
            app.Timer_View.StartDelay = 0;
            app.Timer_View.Period = 0.1 ; %定时器定时中断周期
            app.Timer_View.ExecutionMode = 'fixedDelay';
            app.Timer_View.TimerFcn = @(~,~)TimerObservation_handler(app);
            %start(app.TimerInit_O);
        end
        function TimerObservation_handler(app)
            app.Phase_observation = app.Phase_observation + app.Phase_observation_step;
            if app.Phase_observation >= 2*pi
                app.Phase_observation = 0;
            end
            WaveMake(app);
            ObservationPlot(app);
        end
        function TimerGenerate_handler(app)
            app.Phase_generate = app.Phase_generate + app.Phase_generate_step;
            if app.Phase_generate >= 2*pi
                app.Phase_generate = 0;
            end
            SignalGenerated_draw(app);
        end
        function SignalGenerated_draw(app)
            dt = 1.0/app.Fs;
            time = 0:dt:app.N_Generate * dt;
            if app.SignalTypes.SelectedObject.Text == "SineWave"
                wave = app.AmplitudeGenerate * sin(time .* 2*pi*app.FrequencyGenerate + app.PhaseGenerate + app.Phase_generate);
                plot(app.SignalPreview_axis,time,wave,'LineWidth', 1.5);
            elseif app.SignalTypes.SelectedObject.Text == "SquareWave"
                wave = app.AmplitudeGenerate * square(time .* 2*pi*app.FrequencyGenerate + app.PhaseGenerate + app.Phase_generate);
                plot(app.SignalPreview_axis,time,wave,'LineWidth', 1.5);
            elseif app.SignalTypes.SelectedObject.Text == "TriangularWave"
                wave = app.AmplitudeGenerate * sawtooth(time .* 2*pi*app.FrequencyGenerate + app.PhaseGenerate + app.Phase_generate,0.5);
                plot(app.SignalPreview_axis,time,wave,'LineWidth', 1.5);
            elseif app.SignalTypes.SelectedObject.Text == "WhiteNoise"
                wave = 0.2 *app.AmplitudeGenerate * randn(1,app.N_Generate+1);
                plot(app.SignalPreview_axis,time,wave,'LineWidth', 1.5);
            end
            clear("wave");
            clear("time");

        end

        function Startup_init(app)
            app.FrequencyGenerate = 600; % 信号生成窗口的信号频率(600为初始值)
            app.AmplitudeGenerate = 0.5; % 信号生成窗口的信号幅值(0.5为初始值)
            app.PhaseGenerate = 0; % 信号观测窗口的信号相位
            app.Phase_generate = 0; % 信号生成窗口绘制函数运行相位
            app.Phase_generate_step = 0.1*pi; % 一次计时中断预览窗口的变化步长
            app.Fs = 44100; %采样频率
            app.N_observation = 441*5; %采样长度
            app.N_Generate = 441;
        end
        
        
        function  LockInput(app,odder)
            if odder == 1 % 允许写操作
                app.TextAmplitude.Editable = 'on';
                app.AmplitudeSlider.Enable = 'on';
                app.TextFrequency.Editable = 'on';
                app.FrequencySlider.Enable = 'on';
                app.TextPhase.Editable = 'on';
                app.PhaseSlider.Enable = 'on';
                app.AddSignal.Enable = 'on';
            elseif odder == 0
                app.TextAmplitude.Editable = 'off';
                app.AmplitudeSlider.Enable = 'off';
                app.TextFrequency.Editable = 'off';
                app.FrequencySlider.Enable = 'off';
                app.TextPhase.Editable = 'off';
                app.PhaseSlider.Enable = 'off';
                app.AddSignal.Enable = 'off';
            end
        end
        
        function WaveMake(app)
            dt = 1.0/app.Fs;
            time = 0:dt:app.N_observation * dt;
            Numbers = size(app.InformationStorage,1);
            app.InformationPlot = zeros([Numbers+1,app.N_observation + 1]);
            for i = 1:Numbers
                if app.InformationStorage(i,4) == 1
                    app.InformationPlot(i,:) = app.InformationStorage(i,2) * ...
                        sin(time(:)* 2*pi*app.InformationStorage(i,1) + app.InformationStorage(i,3) + app.Phase_observation);
                elseif app.InformationStorage(i,4) == 2
                    app.InformationPlot(i,:) = app.InformationStorage(i,2) * ...
                        square(time(:)* 2*pi*app.InformationStorage(i,1) + app.InformationStorage(i,3) + app.Phase_observation);
                elseif app.InformationStorage(i,4) == 3
                    app.InformationPlot(i,:) = app.InformationStorage(i,2) * ...
                        sawtooth(time(:)* 2*pi*app.InformationStorage(i,1) + app.InformationStorage(i,3) + app.Phase_observation,0.5);
                elseif app.InformationStorage(i,4) == 4
                    a = randn(1,app.N_observation+1);
                    app.InformationPlot(i,:) = 0.2 *app.InformationStorage(i,2) * a(:);
                end
            end
            for i = 1:app.N_observation + 1
                for j = 1:Numbers
                    app.InformationPlot(Numbers+1,i)=app.InformationPlot(Numbers+1,i)+app.InformationPlot(j,i);
                end
            end
            clear("time");
        end
        
        function ObservationPlot(app)
            dt = 1.0/app.Fs;
            time = 0:dt:app.N_observation * dt;
            cla(app.SignalObservation_axis);
            for i=1:size(app.InformationPlot,1)-1
                plot(app.SignalObservation_axis,time,app.InformationPlot(i,:),'LineWidth',1.5,'LineStyle','--');
                hold(app.SignalObservation_axis,"on");
            end
            a = size(app.InformationPlot,1);
            plot(app.SignalObservation_axis,time(:),app.InformationPlot(a,:),'LineWidth',2);
        end
        
        function stopView (app)
            if app.observation_flag == 1
                stop(app.Timer_View);
                app.observation_flag = 0 ;
            end
        end
        function stopGeneration (app)
            if app.generate_flag == 1
                stop(app.Timer_Generate);
                app.generate_flag = 0 ;
            end
        end
        function startGeneration (app)
            if app.generate_flag == 0
                start(app.Timer_Generate);
                app.generate_flag = 1 ;
            end
        end
        function startView (app)
            if app.observation_flag == 0
                start(app.Timer_View);
                app.observation_flag = 1 ;
            end
        end
    end


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

        % Code that executes after component creation
        function startupFcn(app)
            clc;close;
            Startup_init(app);
            %TimerInit_O(app);
            TimerInit_G(app);

        end

        % Value changed function: TextFrequency
        function TextFrequencyValueChanged(app, event)
            value = app.TextFrequency.Value; % 文本的读取值为cell
            value = cell2double(app,value);
            app.FrequencySlider.Value = value;
            app.FrequencyGenerate = value;
        end

        % Value changed function: FrequencySlider
        function FrequencySliderValueChanged(app, event)
            value = app.FrequencySlider.Value; %滑块的返回值为double
            %value = cell2double(app,value);
            app.FrequencyGenerate = value;
            value = num2str(value);
            app.TextFrequency.Value = value;
        end

        % Value changing function: FrequencySlider
        function FrequencySliderValueChanging(app, event)
            changingValue = event.Value;
            app.FrequencyGenerate = changingValue;
            changingValue = num2str(changingValue);
            app.TextFrequency.Value = changingValue;
        end

        % Value changed function: AmplitudeSlider
        function AmplitudeSliderValueChanged(app, event)
            value = app.AmplitudeSlider.Value;
            app.AmplitudeGenerate = value;
            value = num2str(value);
            app.TextAmplitude.Value = value;

        end

        % Value changing function: AmplitudeSlider
        function AmplitudeSliderValueChanging(app, event)
            changingValue = event.Value;
            app.AmplitudeGenerate = changingValue;
            changingValue = num2str(changingValue);
            app.TextAmplitude.Value = changingValue;
        end

        % Value changed function: TextAmplitude
        function TextAmplitudeValueChanged(app, event)
            value = app.TextAmplitude.Value;
            value = cell2double(app,value);
            app.AmplitudeGenerate = value;
            app.AmplitudeSlider.Value = value;
        end

        % Value changed function: PhaseSlider
        function PhaseSliderValueChanged(app, event)
            value = app.PhaseSlider.Value;
            app.PhaseGenerate = value*pi;
            value = num2str(value);
            app.TextPhase.Value = value;
        end

        % Value changing function: PhaseSlider
        function PhaseSliderValueChanging(app, event)
            changingValue = event.Value;
            app.PhaseGenerate = changingValue * pi;
            changingValue = num2str(changingValue);
            app.TextPhase.Value = changingValue;
        end

        % Value changed function: TextPhase
        function TextPhaseValueChanged(app, event)
            value = app.TextPhase.Value;
            value = cell2double(app,value);
            app.PhaseGenerate = value * pi;
            app.PhaseSlider.Value = value;
        end

        % Button pushed function: AddSignal
        function AddSignalButtonPushed(app, event)
            stopView(app);
            if app.SignalTypes.SelectedObject.Text == "SineWave"
                Type = 1;
            elseif app.SignalTypes.SelectedObject.Text == "SquareWave"
                Type = 2;
            elseif app.SignalTypes.SelectedObject.Text == "TriangularWave"
                Type = 3;
            elseif app.SignalTypes.SelectedObject.Text == "WhiteNoise"
                Type = 4;
            end
            app.InformationStorage = [app.InformationStorage;app.FrequencyGenerate,...
                app.AmplitudeGenerate,app.PhaseGenerate,Type];
            %stopView(app);
            WaveMake(app);
            ObservationPlot(app);
        end

        % Button pushed function: RunObservation
        function RunObservationButtonPushed(app, event)
            LockInput(app,0);
            stopGeneration(app);
            TimerInit_O(app);
            startView(app);
            
            
        end

        % Button pushed function: StopObservation
        function StopObservationButtonPushed(app, event)
            stopView(app);
            startGeneration(app);
            LockInput(app,1);
            app.Phase_observation = 0;
        end

        % Button pushed function: ClearObservation
        function ClearObservationButtonPushed(app, event)
            app.InformationStorage = [0,0,0,1];
            WaveMake(app);
            ObservationPlot(app);
        end

        % Button pushed function: PlayObservation
        function PlayObservationButtonPushed(app, event)
            %stopView(app);
            % 懒得重改了,直接堆叠
            dt = 1.0/app.Fs;
            time = 0:dt:44100 * dt;
            Numbers = size(app.InformationStorage,1);
            MyInformationPlot = zeros([Numbers+1,44100 + 1]);
            for i = 1:Numbers
                if app.InformationStorage(i,4) == 1
                    MyInformationPlot(i,:) = app.InformationStorage(i,2) * ...
                        sin(time(:)* 2*pi*app.InformationStorage(i,1) + app.InformationStorage(i,3) + app.Phase_observation);
                elseif app.InformationStorage(i,4) == 2
                    MyInformationPlot(i,:) = app.InformationStorage(i,2) * ...
                        square(time(:)* 2*pi*app.InformationStorage(i,1) + app.InformationStorage(i,3) + app.Phase_observation);
                elseif app.InformationStorage(i,4) == 3
                    MyInformationPlot(i,:) = app.InformationStorage(i,2) * ...
                        sawtooth(time(:)* 2*pi*app.InformationStorage(i,1) + app.InformationStorage(i,3) + app.Phase_observation,0.5);
                elseif app.InformationStorage(i,4) == 4
                    a = randn(1,44100+1);
                    MyInformationPlot(i,:) = 0.2 *app.InformationStorage(i,2) * a(:);
                end
            end
            for i = 1:44100 + 1
                for j = 1:Numbers
                    MyInformationPlot(Numbers+1,i)=MyInformationPlot(Numbers+1,i)+MyInformationPlot(j,i);
                end
            end
            sound(MyInformationPlot(size(MyInformationPlot,1),:),app.Fs);
            %startView(app);

        end

        % Button pushed function: Analysis
        function AnalysisButtonPushed(app, event)
            dt = 1.0/app.Fs;
            Limit_X = size(app.InformationPlot,1);
            Limit_Y = size(app.InformationPlot,2);
            app.Peak.Value = max(app.InformationPlot(Limit_X,:));
            app.Grain.Value = min(app.InformationPlot(Limit_X,:));
            app.Peak_Grain.Value = app.Peak.Value - app.Grain.Value;
            for i = 1:Limit_Y
                if app.InformationPlot(Limit_X,i) == app.Peak.Value
                    serial_peak = i;
                    break;
                end
            end
            for i = 1:Limit_Y
                if app.InformationPlot(Limit_X,i) == app.Grain.Value
                    serial_grain = i;
                    break;
                end
            end
            app.Mean.Value = mean(app.InformationPlot(Limit_X,:));
            app.STD_error.Value = std(app.InformationPlot(Limit_X,:));
            app.RMS.Value = sqrt( mean(app.InformationPlot(Limit_X,:) .^2 )   );
            M = 4096;
            P = fft(app.InformationPlot(Limit_X,:),M);
            Py = 2 * sqrt(P.*conj(P))/M;
            f = linspace(0,app.Fs/2,M/2);
            plot(app.UIAxes,f,Py(1:M/2));
        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 955 677];
            app.UIFigure.Name = 'MATLAB App';

            % Create SignalGenerated
            app.SignalGenerated = uipanel(app.UIFigure);
            app.SignalGenerated.ForegroundColor = [0.2784 0.5804 0.7686];
            app.SignalGenerated.TitlePosition = 'centertop';
            app.SignalGenerated.Title = '信号生成';
            app.SignalGenerated.FontWeight = 'bold';
            app.SignalGenerated.Position = [2 1 276 677];

            % Create SignalPreview_axis
            app.SignalPreview_axis = uiaxes(app.SignalGenerated);
            title(app.SignalPreview_axis, '信号预览')
            app.SignalPreview_axis.XLim = [0 0.01];
            app.SignalPreview_axis.YLim = [-2.1 2.1];
            app.SignalPreview_axis.GridLineStyle = ':';
            app.SignalPreview_axis.XTick = [0 0.005 0.01];
            app.SignalPreview_axis.XGrid = 'on';
            app.SignalPreview_axis.YGrid = 'on';
            app.SignalPreview_axis.Box = 'on';
            app.SignalPreview_axis.Position = [1 399 273 250];

            % Create SignalTypes
            app.SignalTypes = uibuttongroup(app.SignalGenerated);
            app.SignalTypes.TitlePosition = 'centertop';
            app.SignalTypes.Title = '信号类型';
            app.SignalTypes.Position = [-2 325 277 75];

            % Create WhiteNoise
            app.WhiteNoise = uiradiobutton(app.SignalTypes);
            app.WhiteNoise.Text = 'WhiteNoise';
            app.WhiteNoise.FontName = '3ds Light';
            app.WhiteNoise.Position = [11 27 84 22];

            % Create SineWave
            app.SineWave = uiradiobutton(app.SignalTypes);
            app.SineWave.Text = 'SineWave';
            app.SineWave.Position = [11 5 76 22];
            app.SineWave.Value = true;

            % Create TriangularWave
            app.TriangularWave = uiradiobutton(app.SignalTypes);
            app.TriangularWave.Text = 'TriangularWave';
            app.TriangularWave.Position = [149 26 106 22];

            % Create SquareWave
            app.SquareWave = uiradiobutton(app.SignalTypes);
            app.SquareWave.Text = 'SquareWave';
            app.SquareWave.Position = [149 5 91 22];

            % Create FrequencySlider
            app.FrequencySlider = uislider(app.SignalGenerated);
            app.FrequencySlider.Limits = [10 3000];
            app.FrequencySlider.ValueChangedFcn = createCallbackFcn(app, @FrequencySliderValueChanged, true);
            app.FrequencySlider.ValueChangingFcn = createCallbackFcn(app, @FrequencySliderValueChanging, true);
            app.FrequencySlider.Position = [14 271 249 3];
            app.FrequencySlider.Value = 600;

            % Create AmplitudeSlider
            app.AmplitudeSlider = uislider(app.SignalGenerated);
            app.AmplitudeSlider.Limits = [0 2];
            app.AmplitudeSlider.ValueChangedFcn = createCallbackFcn(app, @AmplitudeSliderValueChanged, true);
            app.AmplitudeSlider.ValueChangingFcn = createCallbackFcn(app, @AmplitudeSliderValueChanging, true);
            app.AmplitudeSlider.Position = [12 172 252 3];
            app.AmplitudeSlider.Value = 0.5;

            % Create Label
            app.Label = uilabel(app.SignalGenerated);
            app.Label.HorizontalAlignment = 'right';
            app.Label.Position = [41 294 29 22];
            app.Label.Text = '频率';

            % Create TextFrequency
            app.TextFrequency = uitextarea(app.SignalGenerated);
            app.TextFrequency.ValueChangedFcn = createCallbackFcn(app, @TextFrequencyValueChanged, true);
            app.TextFrequency.HorizontalAlignment = 'right';
            app.TextFrequency.WordWrap = 'off';
            app.TextFrequency.Position = [85 293 150 24];
            app.TextFrequency.Value = {'600'};

            % Create Label_2
            app.Label_2 = uilabel(app.SignalGenerated);
            app.Label_2.HorizontalAlignment = 'right';
            app.Label_2.Position = [41 200 29 22];
            app.Label_2.Text = '幅值';

            % Create TextAmplitude
            app.TextAmplitude = uitextarea(app.SignalGenerated);
            app.TextAmplitude.ValueChangedFcn = createCallbackFcn(app, @TextAmplitudeValueChanged, true);
            app.TextAmplitude.HorizontalAlignment = 'right';
            app.TextAmplitude.Position = [85 199 150 24];
            app.TextAmplitude.Value = {'0.5'};

            % Create AddSignal
            app.AddSignal = uibutton(app.SignalGenerated, 'push');
            app.AddSignal.ButtonPushedFcn = createCallbackFcn(app, @AddSignalButtonPushed, true);
            app.AddSignal.Position = [84 13 114 22];
            app.AddSignal.Text = {'Add'; ''};

            % Create PhaseSlider
            app.PhaseSlider = uislider(app.SignalGenerated);
            app.PhaseSlider.Limits = [0 2];
            app.PhaseSlider.ValueChangedFcn = createCallbackFcn(app, @PhaseSliderValueChanged, true);
            app.PhaseSlider.ValueChangingFcn = createCallbackFcn(app, @PhaseSliderValueChanging, true);
            app.PhaseSlider.Position = [11 76 252 3];

            % Create radLabel
            app.radLabel = uilabel(app.SignalGenerated);
            app.radLabel.HorizontalAlignment = 'right';
            app.radLabel.Position = [3 104 66 22];
            app.radLabel.Text = '相位(π rad)';

            % Create TextPhase
            app.TextPhase = uitextarea(app.SignalGenerated);
            app.TextPhase.ValueChangedFcn = createCallbackFcn(app, @TextPhaseValueChanged, true);
            app.TextPhase.HorizontalAlignment = 'right';
            app.TextPhase.Position = [84 103 150 24];
            app.TextPhase.Value = {'0'};

            % Create SignalObservation
            app.SignalObservation = uipanel(app.UIFigure);
            app.SignalObservation.ForegroundColor = [0.2784 0.5804 0.7686];
            app.SignalObservation.TitlePosition = 'centertop';
            app.SignalObservation.Title = '信号观测';
            app.SignalObservation.FontWeight = 'bold';
            app.SignalObservation.Position = [277 222 679 456];

            % Create SignalObservation_axis
            app.SignalObservation_axis = uiaxes(app.SignalObservation);
            app.SignalObservation_axis.XLim = [0 0.02];
            app.SignalObservation_axis.YLim = [-3.5 3.5];
            app.SignalObservation_axis.GridLineStyle = ':';
            app.SignalObservation_axis.XGrid = 'on';
            app.SignalObservation_axis.YGrid = 'on';
            app.SignalObservation_axis.Position = [1 50 677 385];

            % Create RunObservation
            app.RunObservation = uibutton(app.SignalObservation, 'push');
            app.RunObservation.ButtonPushedFcn = createCallbackFcn(app, @RunObservationButtonPushed, true);
            app.RunObservation.Position = [34 14 100 22];
            app.RunObservation.Text = 'Run';

            % Create StopObservation
            app.StopObservation = uibutton(app.SignalObservation, 'push');
            app.StopObservation.ButtonPushedFcn = createCallbackFcn(app, @StopObservationButtonPushed, true);
            app.StopObservation.Position = [205 14 100 22];
            app.StopObservation.Text = 'Stop';

            % Create PlayObservation
            app.PlayObservation = uibutton(app.SignalObservation, 'push');
            app.PlayObservation.ButtonPushedFcn = createCallbackFcn(app, @PlayObservationButtonPushed, true);
            app.PlayObservation.Position = [545 14 100 22];
            app.PlayObservation.Text = 'Play';

            % Create ClearObservation
            app.ClearObservation = uibutton(app.SignalObservation, 'push');
            app.ClearObservation.ButtonPushedFcn = createCallbackFcn(app, @ClearObservationButtonPushed, true);
            app.ClearObservation.Position = [375 14 100 22];
            app.ClearObservation.Text = 'Clear';

            % Create SignalAnalysis
            app.SignalAnalysis = uipanel(app.UIFigure);
            app.SignalAnalysis.ForegroundColor = [0.2784 0.5804 0.7686];
            app.SignalAnalysis.TitlePosition = 'centertop';
            app.SignalAnalysis.Title = '信号分析';
            app.SignalAnalysis.FontWeight = 'bold';
            app.SignalAnalysis.Position = [277 1 679 222];

            % Create UIAxes
            app.UIAxes = uiaxes(app.SignalAnalysis);
            app.UIAxes.XGrid = 'on';
            app.UIAxes.YGrid = 'on';
            app.UIAxes.Position = [2 2 358 199];

            % Create Label_3
            app.Label_3 = uilabel(app.SignalAnalysis);
            app.Label_3.HorizontalAlignment = 'right';
            app.Label_3.Position = [362 162 29 22];
            app.Label_3.Text = '波峰';

            % Create Peak
            app.Peak = uieditfield(app.SignalAnalysis, 'numeric');
            app.Peak.Editable = 'off';
            app.Peak.Position = [406 162 100 22];

            % Create Label_5
            app.Label_5 = uilabel(app.SignalAnalysis);
            app.Label_5.HorizontalAlignment = 'right';
            app.Label_5.Position = [523 162 29 22];
            app.Label_5.Text = '波谷';

            % Create Grain
            app.Grain = uieditfield(app.SignalAnalysis, 'numeric');
            app.Grain.Editable = 'off';
            app.Grain.Position = [567 162 100 22];

            % Create Label_6
            app.Label_6 = uilabel(app.SignalAnalysis);
            app.Label_6.HorizontalAlignment = 'right';
            app.Label_6.Position = [511 113 41 22];
            app.Label_6.Text = '双峰值';

            % Create Peak_Grain
            app.Peak_Grain = uieditfield(app.SignalAnalysis, 'numeric');
            app.Peak_Grain.Editable = 'off';
            app.Peak_Grain.Position = [567 113 100 22];

            % Create Label_7
            app.Label_7 = uilabel(app.SignalAnalysis);
            app.Label_7.HorizontalAlignment = 'right';
            app.Label_7.Position = [360 113 32 22];
            app.Label_7.Text = 'RMS';

            % Create RMS
            app.RMS = uieditfield(app.SignalAnalysis, 'numeric');
            app.RMS.Editable = 'off';
            app.RMS.Position = [407 113 100 22];

            % Create Label_8
            app.Label_8 = uilabel(app.SignalAnalysis);
            app.Label_8.HorizontalAlignment = 'right';
            app.Label_8.Position = [523 66 29 22];
            app.Label_8.Text = '均值';

            % Create Mean
            app.Mean = uieditfield(app.SignalAnalysis, 'numeric');
            app.Mean.Editable = 'off';
            app.Mean.Position = [567 66 100 22];

            % Create Analysis
            app.Analysis = uibutton(app.SignalAnalysis, 'push');
            app.Analysis.ButtonPushedFcn = createCallbackFcn(app, @AnalysisButtonPushed, true);
            app.Analysis.Position = [564 29 104 24];
            app.Analysis.Text = '分析';

            % Create PoweredbyVulcan_QLabel
            app.PoweredbyVulcan_QLabel = uilabel(app.SignalAnalysis);
            app.PoweredbyVulcan_QLabel.FontSize = 10;
            app.PoweredbyVulcan_QLabel.FontColor = [0.651 0.651 0.651];
            app.PoweredbyVulcan_QLabel.Position = [558 2 118 22];
            app.PoweredbyVulcan_QLabel.Text = 'Powered by Vulcan_Q😋';

            % Create DigitalSignalGenerationandAnalyzerLabel
            app.DigitalSignalGenerationandAnalyzerLabel = uilabel(app.SignalAnalysis);
            app.DigitalSignalGenerationandAnalyzerLabel.HorizontalAlignment = 'right';
            app.DigitalSignalGenerationandAnalyzerLabel.FontSize = 10;
            app.DigitalSignalGenerationandAnalyzerLabel.FontColor = [0.651 0.651 0.651];
            app.DigitalSignalGenerationandAnalyzerLabel.Position = [344 2 203 22];
            app.DigitalSignalGenerationandAnalyzerLabel.Text = 'Digital Signal Generation and Analyzer   ';

            % Create Label_9
            app.Label_9 = uilabel(app.SignalAnalysis);
            app.Label_9.HorizontalAlignment = 'right';
            app.Label_9.Position = [352 66 41 22];
            app.Label_9.Text = '标准差';

            % Create STD_error
            app.STD_error = uieditfield(app.SignalAnalysis, 'numeric');
            app.STD_error.Editable = 'off';
            app.STD_error.Position = [408 66 100 22];

            % 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 = Digital_signal_generation_and_analyzer_exported

            % Create UIFigure and components
            createComponents(app)

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

            % Execute the startup function
            runStartupFcn(app, @startupFcn)

            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
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值