matlab app designer学习笔记1——简易计算器

设计视图:

 代码视图

代码:

 % Button pushed function: add
        function addButtonPushed(app, event)
            x=app.num1.Value;
            y=app.num2.Value;
            app.result.Value=x+y;
        end

        % Button pushed function: subtract
        function subtractButtonPushed(app, event)
            x=app.num1.Value;
            y=app.num2.Value;
            app.result.Value=x-y;
        end

        % Button pushed function: multiply
        function multiplyButtonPushed(app, event)
            x=app.num1.Value;
            y=app.num2.Value;
            app.result.Value=x*y;
        end

        % Button pushed function: divide
        function divideButtonPushed(app, event)
            x=app.num1.Value;
            y=app.num2.Value;
            app.result.Value=x/y;
        end

 运行结果:

 


版权声明:本文为weixin_46674612原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。