MATLAB 计算器,函数图形绘制,图片展示 APP Designer 版本

该博客介绍了一个使用MATLAB App Designer构建的科学计算器应用,具有左右对分和上下对分的布局。左侧是计算器,右侧分为两部分,上方用于绘制函数图像,下方显示图片。计算器支持基本运算及科学计算,如平方、开方、指数等,并能通过等号键进行计算。函数图像部分允许输入数学表达式并实时绘制。此外,应用还具备清除、退格等功能。代码中详细定义了各个按钮的回调函数,实现了计算器的各种操作逻辑。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

编写科学计算器,(要求)左右对分,右边上下对分,左边是科学计算器,右上是画函数图像,右下显示任意格式的图片

全部代码在文末百度云链接。

 效果如上图所示,需要在设计视图拖入 面板,按钮,坐标区,编辑字段文本,图像,这些组件库

 

 

 

 

 

 

添加按钮1的回调函数

 

 

按钮1的回调函数设置,其他按钮类似,只需要改变‘1’里面的值,是2就改成2,是+就改成+

 

唯一有区别的是等号键,退格键和清空键

 等于的思路就是把输出文本框里面的文本转换为数值格式然后用eval函数进行计算然后赋值给文本框。

 

 

全部代码如下:

classdef mode < matlab.apps.AppBase

    % Properties that correspond to app components
    properties (Access = public)
        MatlabUIFigure  matlab.ui.Figure
        Label_3         matlab.ui.control.Label
        Button          matlab.ui.control.Button
        ysinxTextArea   matlab.ui.control.TextArea
        ysinxLabel      matlab.ui.control.Label
        Panel           matlab.ui.container.Panel
        textString      matlab.ui.control.TextArea
        Label           matlab.ui.control.Label
        dengyu          matlab.ui.control.Button
        clc             matlab.ui.control.Button
        dian            matlab.ui.control.Button
        zero            matlab.ui.control.Button
        three           matlab.ui.control.Button
        two             matlab.ui.control.Button
        one             matlab.ui.control.Button
        jian            matlab.ui.control.Button
        six             matlab.ui.control.Button
        five            matlab.ui.control.Button
        four            matlab.ui.control.Button
        add             matlab.ui.control.Button
        nigh            matlab.ui.control.Button
        eight           matlab.ui.control.Button
        siven           matlab.ui.control.Button
        tuige           matlab.ui.control.Button
        chengyi         matlab.ui.control.Button
        chuyi           matlab.ui.control.Button
        pingfang        matlab.ui.control.Button
        Image           matlab.ui.control.Image
        UIAxes          matlab.ui.control.UIAxes
    end


    
    methods (Access = private)
        
      
    function results = PlotStep(app,value)%Plot
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

皮皮牛牛

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值