classdef SendData < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        UIFigure               matlab.ui.Figure
        NumericEditField       matlab.ui.control.NumericEditField
        LabelNumericEditField  matlab.ui.control.Label
        Button                 matlab.ui.control.Button
    end

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

        % Code that executes after component creation
        function startupFcn(app)
            
        end

        % Button pushed function: Button
        function ButtonButtonPushed(app, event)
            v = app.NumericEditField.Value;
            assignin('base','Value_App1', v);
        end

        % Close request function: UIFigure
        function UIFigureCloseRequest(app, event)
            v = app.NumericEditField.Value;
            assignin('base','Value_App1', v);
            delete(app);
        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 = [101 101 249 160];
            app.UIFigure.Name = 'UI Figure';
            app.UIFigure.CloseRequestFcn = createCallbackFcn(app, @UIFigureCloseRequest, true);

            % Create Button
            app.Button = uibutton(app.UIFigure, 'push');
            app.Button.ButtonPushedFcn = createCallbackFcn(app, @ButtonButtonPushed, true);
            app.Button.Position = [69 47 114 22];
            app.Button.Text = 'Send';

            % Create LabelNumericEditField
            app.LabelNumericEditField = uilabel(app.UIFigure);
            app.LabelNumericEditField.HorizontalAlignment = 'right';
            app.LabelNumericEditField.VerticalAlignment = 'top';
            app.LabelNumericEditField.Position = [52 100 32 15];
            app.LabelNumericEditField.Text = 'Value';

            % Create NumericEditField
            app.NumericEditField = uieditfield(app.UIFigure, 'numeric');
            app.NumericEditField.Position = [99 96 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 = SendData

            % 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