利用MATLAB的App设计一个简单的计算器和程序员计算器,界面如图:
标准计算器界面
程序员计算器界面
点击菜单选择普通简单计算器界面或者程序员计算器界面,在Input可编辑文本中输入计算的表达式——点击等号或者点击进制转换的按键 ——在Result出现结果。需要完整App安装包的,可以进行在微信公众号云龙派打赏后截图(40元及以上),点击公众号“联系掌门”进行联系,或者在公众号内回复截图,几小时内会回复。App编程不易,还请见谅!
主要功能按键介绍:
close:退出App
back:返回上一次的输入
clean:清除input输入文本框内容
DEC2OCT:十进制转换为八进制数
OCT2DEC:八进制转换为十进制数
DEC2BIN:十进制转换为二进制数
BIN2DEC:二进制转换为十进制数
DEC2HEX:十进制转换为十六进制
HEX2DEC:十六进制转换为十进制
1.计算功能操作示意
Step1:点击Calculator.mlappinstall文件,在MATLAB中双击安装APP,点击安装到我的APP。
Step2:在APP 菜单栏中找到我的app中的Calculator,双击运行出App主界面
Step3:默认状态是在标准计算器界面,可以通过按键在Input文本框里输入想要进行运算的表达式,点击等号即可在Result文本框中显示出结果。
Step4:点击菜单栏,进入到程序员计算器界面,可以通过按键在Input文本框里输入想要进行运算的数据,点击相应的进制转换即可在Result文本框中显示出结果。
2.App部分程序
classdef calculatorapp < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
CalculatorUIFigure matlab.ui.Figure
TabGroup matlab.ui.container.TabGroup
Tab matlab.ui.container.Tab
atanButton matlab.ui.control.Button
sqrtButton matlab.ui.control.Button
Button_32 matlab.ui.control.Button
Button_31 matlab.ui.control.Button
Button_29 matlab.ui.control.Button
InputEditField matlab.ui.control.EditField
InputEditFieldLabel matlab.ui.control.Label
ResultEditField matlab.ui.control.NumericEditField
ResultEditFieldLabel matlab.ui.control.Label
Button_30 matlab.ui.control.Button
cleanButton_3 matlab.ui.control.Button
logButton_2 matlab.ui.control.Button
Button_28 matlab.ui.control.Button
tanButton matlab.ui.control.Button
cosButton matlab.ui.control.Button
sinButton matlab.ui.control.Button
backButton matlab.ui.control.Button
Button_27 matlab.ui.control.Button
Button_26 matlab.ui.control.Button
Button_25 matlab.ui.control.Button
Button_24 matlab.ui.control.Button
Button_23 matlab.ui.control.Button
Button_22 matlab.ui.control.Button
closeButton_2 matlab.ui.control.Button
Button_21 matlab.ui.control.Button
Button_20 matlab.ui.control.Button
Button_19 matlab.ui.control.Button
Button_17 matlab.ui.control.Button
Button_16 matlab.ui.control.Button
Button_15 matlab.ui.control.Button
Button_14 matlab.ui.control.Button
Button_13 matlab.ui.control.Button
Tab_2 matlab.ui.container.Tab
XButton matlab.ui.control.Button
Button_34 matlab.ui.control.Button
Button_33 matlab.ui.control.Button
FButton matlab.ui.control.Button
EButton matlab.ui.control.Button
DButton matlab.ui.control.Button
CButton matlab.ui.control.Button
BButton matlab.ui.control.Button
ResultEditField_2 matlab.ui.control.EditField
ResultEditField_2Label matlab.ui.control.Label
OCT2DECButton matlab.ui.control.Button
DEC2OCTButton matlab.ui.control.Button
HEX2DECButton matlab.ui.control.Button
InputEditField_2 matlab.ui.control.EditField
InputEditField_2Label matlab.ui.control.Label
DEC2HEXButton matlab.ui.control.Button
BIN2DECButton matlab.ui.control.Button
DEC2BINButton matlab.ui.control.Button
cleanButton_2 matlab.ui.control.Button
backButton_2 matlab.ui.control.Button
AButton matlab.ui.control.Button
Button_11 matlab.ui.control.Button
closeButton matlab.ui.control.Button
Button_9 matlab.ui.control.Button
Button_8 matlab.ui.control.Button
Button_7 matlab.ui.control.Button
Button_6 matlab.ui.control.Button
Button_5 matlab.ui.control.Button
Button_4 matlab.ui.control.Button
Button_3 matlab.ui.control.Button
Button_2 matlab.ui.control.Button
Button matlab.ui.control.Button
end
properties (Access = private)
textString % Description
textString1
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: Button_13
function Button_13Pushed(app, event)
textString = app.InputEditField.Value;
textString = strcat(textString,'1');
app.InputEditField.Value = textString;
end
本文内容来源于网络,仅供参考学习,如内容、图片有任何版权问题,请联系处理,24小时内删除。
作 者 | 郭志龙
编 辑 | 郭志龙
校 对 | 郭志龙