matlab做计算器,怎样用MATLAB中的GUI做一个简单计算器

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼

function varargout = jisuanqi(varargin)

gui_Singleton = 1;

gui_State = struct('gui_Name', mfilename, ...

'gui_Singleton', gui_Singleton, ...

'gui_OpeningFcn', @jisuanqi_OpeningFcn, ...

'gui_OutputFcn', @jisuanqi_OutputFcn, ...

'gui_LayoutFcn', [] , ...

'gui_Callback', []);

if nargin && ischar(varargin{1})

gui_State.gui_Callback = str2func(varargin{1});

end

if nargout

[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});

else

gui_mainfcn(gui_State, varargin{:});

end

function jisuanqi_OpeningFcn(hObject, eventdata, handles, varargin)

global x wei suanfu dian dian_i chucun panduan m

m=0;

panduan=0;

chucun=0;

dian_i=0;

dian=0;

suanfu=0;

wei=0;

x=0;

handles.output = hObject;

guidata(hObject, handles);

function varargout = jisuanqi_OutputFcn(hObject, eventdata, handles)

varargout{1} = handles.output;

function yi_Callback(hObject, eventdata, handles)

y=1;

global x wei dian dian_i panduan

if dian==0

if wei==1

x=x*10+y;

else wei==0

x=y;

end

else dian==1

x=x+y/10^dian_i;

dian_i=dian_i+1;

end

wei=1;

panduan=0;

set(handles.xianshi,'string',x)

function ba_Callback(hObject, eventdata, handles)

y=8;

global x wei dian dian_i panduan

if dian==0

if wei==1

x=x*10+y;

else wei==0

x=y;

end

else dian==1

x=x+y/10^dian_i;

dian_i=dian_i+1;

end

wei=1;

panduan=0;

set(handles.xianshi,'string',x)

function qi_Callback(hObject, eventdata, handles)

y=7;

global x wei dian dian_i panduan

if dian==0

if wei==1

x=x*10+y;

else wei==0

x=y;

end

else dian==1

x=x+y/10^dian_i;

dian_i=dian_i+1;

end

wei=1;panduan=0;

set(handles.xianshi,'string',x)

function liu_Callback(hObject, eventdata, handles)

y=6;

global x wei dian dian_i panduan

if dian==0

if wei==1

x=x*10+y;

else wei==0

x=y;

end

else dian==1

x=x+y/10^dian_i;

dian_i=dian_i+1;

end

wei=1;

panduan=0;

set(handles.xianshi,'string',x)

function wu_Callback(hObject, eventdata, handles)

y=5;

global x wei dian dian_i panduan

if dian==0

if wei==1

x=x*10+y;

else wei==0

x=y;

end

else dian==1

x=x+y/10^dian_i;

dian_i=dian_i+1;

end

wei=1;

panduan=0;

set(handles.xianshi,'string',x)

function si_Callback(hObject, eventdata, handles)

y=4;

global x wei dian dian_i panduan

if dian==0

if wei==1

x=x*10+y;

else wei==0

x=y;

end

else dian==1

x=x+y/10^dian_i;

dian_i=dian_i+1;

end

wei=1;

panduan=0;

set(handles.xianshi,'string',x)

function san_Callback(hObject, eventdata, handles)

y=3;

global x wei dian dian_i panduan

if dian==0

if wei==1

x=x*10+y;

else wei==0

x=y;

end

else dian==1

x=x+y/10^dian_i;

dian_i=dian_i+1;

end

wei=1;

panduan=0;

set(handles.xianshi,'string',x)

function er_Callback(hObject, eventdata, handles)

y=2;

global x wei dian dian_i panduan

if dian==0

if wei==1

x=x*10+y;

else wei==0

x=y;

end

else dian==1

x=x+y/10^dian_i;

dian_i=dian_i+1;

end

wei=1;

panduan=0;

set(handles.xianshi,'string',x)

function jiu_Callback(hObject, eventdata, handles)

y=9;

global x wei dian dian_i panduan

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值