classdef calculator_exported < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
TextArea matlab.ui.control.TextArea
Button matlab.ui.control.Button
Button_2 matlab.ui.control.Button
Button_3 matlab.ui.control.Button
Button_4 matlab.ui.control.Button
Button_5 matlab.ui.control.Button
Button_6 matlab.ui.control.Button
Button_7 matlab.ui.control.Button
Button_8 matlab.ui.control.Button
Button_9 matlab.ui.control.Button
Button_10 matlab.ui.control.Button
Button_11 matlab.ui.control.Button
Button_12 matlab.ui.control.Button
Button_13 matlab.ui.control.Button
Button_14 matlab.ui.control.Button
Button_15 matlab.ui.control.Button
Button_16 matlab.ui.control.Button
Button_17 matlab.ui.control.Button
xButton matlab.ui.control.Button
Button_21 matlab.ui.control.Button
CButton matlab.ui.control.Button
Button_18 matlab.ui.control.Button
xButton_2 matlab.ui.control.Button
Button_20 matlab.ui.control.Button
end
properties (Access = private)
express_str = '' % the expression string
ans = '' % the answer
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: Button
function Num_0Pushed(app, event)
if strcmp(app.TextArea.Value,'0')
else
app.express_str = strcat(app.express_str,'0');
app.TextArea.Value = app.express_str;
end
end
% Button pushed function: Button_3
function Num_1Pushed(app, event)
app.express_str = strcat(app.express_str,'1');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_4
function Num_2Pushed(app, event)
app.express_str = strcat(app.express_str,'2');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_5
function Num_3Pushed(app, event)
app.express_str = strcat(app.express_str,'3');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_9
function Num_4Pushed(app, event)
app.express_str = strcat(app.express_str,'4');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_8
function Num_5Pushed(app, event)
app.express_str = strcat(app.express_str,'5');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_7
function Num_6Pushed(app, event)
app.express_str = strcat(app.express_str,'6');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_12
function Num_7Pushed(app, event)
app.express_str = strcat(app.express_str,'7');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_11
function Num_8Pushed(app, event)
app.express_str = strcat(app.express_str,'8');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_10
function Num_9Pushed(app, event)
app.express_str = strcat(app.express_str,'9');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_6
function Dot_Pushed(app, event)
app.express_str = strcat(app.express_str,'.');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_20
function Lbracket_Pushed(app, event)
app.express_str = strcat(app.express_str,'(');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_21
function Rbracket_Pushed(app, event)
app.express_str = strcat(app.express_str,')');
app.TextArea.Value = app.express_str;
end
% Button pushed function: xButton
function Squre_Pushed(app, event)
app.express_str = strcat(app.express_str,'^2');
app.TextArea.Value = app.express_str;
end
% Button pushed function: CButton
function Clear_Pushed(app, event)
app.express_str = '';
app.TextArea.Value = '0';
end
% Button pushed function: Button_18
function Delete_Pushed(app, event)
tail = length(app.express_str);
app.express_str = app.express_str(1,1:tail-1);
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_13
function Divide_Pushed(app, event)
app.express_str = strcat(app.express_str,'/');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_14
function Multip_Pushed(app, event)
app.express_str = strcat(app.express_str,'*');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_15
function Sub_Pushed(app, event)
app.express_str = strcat(app.express_str,'-');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_16
function Add_Pushed(app, event)
app.express_str = strcat(app.express_str,'+');
app.TextArea.Value = app.express_str;
end
% Button pushed function: xButton_2
function Invert_Pushed(app, event)
if length(app.express_str)>0
try
result = eval(app.express_str);
app.ans = num2str(1/result);
app.express_str = app.ans;
app.TextArea.Value = app.ans;
catch
app.express_str = '';
app.TextArea.Value = 'error';
end
end
end
% Button pushed function: Button_17
function Pow_Pushed(app, event)
app.express_str = strcat(app.express_str,'^');
app.TextArea.Value = app.express_str;
end
% Button pushed function: Button_2
function Equal_Pushed(app, event)
if length(app.express_str)>0
try
result = eval(app.express_str);
app.ans = num2str(result);
app.express_str = app.ans;
app.TextArea.Value = app.ans;
catch
app.express_str = '';
app.TextArea.Value = 'error';
end
end
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 357 481];
app.UIFigure.Name = 'MATLAB App';
% Create TextArea
app.TextArea = uitextarea(app.UIFigure);
app.TextArea.Tag = 'result';
app.TextArea.Editable = 'off';
app.TextArea.HorizontalAlignment = 'right';
app.TextArea.FontSize = 24;
app.TextArea.Position = [38 351 285 79];
app.TextArea.Value = {'0'};
% Create Button
app.Button = uibutton(app.UIFigure, 'push');
app.Button.ButtonPushedFcn = createCallbackFcn(app, @Num_0Pushed, true);
app.Button.Tag = '0';
app.Button.FontSize = 24;
app.Button.Position = [38 63 100 42];
yava_free
- 粉丝: 4811
- 资源: 1848
最新资源
- 基于STM32为电子香味项目,通过蓝牙模块传输数据,嵌入式硬件平台,RFID使用的是RC522.整个项目包括软硬件以及android程序详细文档+全部资料+高分项目+源码.zip
- 基于发布-订阅模型的多线程消息框架,用于嵌入式平台,纯C实现,性能和灵活性极高详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式Linux的一套可视对讲设备代码,比较底层,写的比较好,里面的lib库是一些图像处理库详细文档+全部资料+高分项目+源码.zip
- php 实现各种排序和查找算法源代码.zip
- 基于嵌入式qt的车载系统详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式的基础图形库详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式平台ARM Linux的新冠肺炎疫情监控平台详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式的视觉运动控制详细文档+全部资料+高分项目+源码.zip
- 基于嵌入式综合项目:STM32F407基于ARM Cortex-M4处理器,云服务器Linux操作系统,MySQL数据存储转发详细文档+全部资料+高分项目+源码
- 基于热风控制系统嵌入式项目,基于STM32F1芯片和RT-Thread实时系统开发出温度闭环控制和风速控制详细文档+全部资料+高分项目+源码.zip
- 基于全志V3S的嵌入式开发者打怪升级项目详细文档+全部资料+高分项目+源码.zip
- 基于事件型嵌入式驱动框架。详细文档+全部资料+高分项目+源码.zip
- 基于使用B-Tree作为索引,基于MMap的嵌入式键值数据库详细文档+全部资料+高分项目+源码.zip
- 基于三个嵌入式的小项目:一个是基于科大讯飞的语音识别系统,一个是智能音乐相册,一个是别踩白块小游戏详细文档+全部资料+高分项目+源码.zip
- 基于物联网模式开发的嵌入式程序详细文档+全部资料+高分项目+源码.zip
- 基于以太网通信的电力电子设备运行状态的远程监控嵌入式系统设计详细文档+全部资料+高分项目+源码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈