用MATLAB实现计算器程序源代码.docx

上传人:b****8 文档编号:10950499 上传时间:2023-02-23 格式:DOCX 页数:16 大小:16.14KB
下载 相关 举报
用MATLAB实现计算器程序源代码.docx_第1页
第1页 / 共16页
用MATLAB实现计算器程序源代码.docx_第2页
第2页 / 共16页
用MATLAB实现计算器程序源代码.docx_第3页
第3页 / 共16页
用MATLAB实现计算器程序源代码.docx_第4页
第4页 / 共16页
用MATLAB实现计算器程序源代码.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

用MATLAB实现计算器程序源代码.docx

《用MATLAB实现计算器程序源代码.docx》由会员分享,可在线阅读,更多相关《用MATLAB实现计算器程序源代码.docx(16页珍藏版)》请在冰豆网上搜索。

用MATLAB实现计算器程序源代码.docx

用MATLAB实现计算器程序源代码

functionvarargout=caculator(varargin)

gui_Singleton=1;

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

'gui_Singleton',gui_Singleton,...

'gui_OpeningFcn',@caculator_OpeningFcn,...

'gui_OutputFcn',@caculator_OutputFcn,...

'gui_LayoutFcn',[],...

'gui_Callback',[]);

ifnargin&&ischar(varargin{1})

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

end

ifnargout

[varargout{1:

nargout}]=gui_mainfcn(gui_State,varargin{:

});

else

gui_mainfcn(gui_State,varargin{:

});

end

functioncaculator_OpeningFcn(hObject,eventdata,handles,varargin)

handles.output=hObject;

set(handles.edit1,'string','0');

set(handles.edit5,'string','0');

guidata(hObject,handles);

functionvarargout=caculator_OutputFcn(hObject,eventdata,handles)

varargout{1}=handles.output;

functionedit1_Callback(hObject,eventdata,handles)

functionedit1_CreateFcn(hObject,eventdata,handles)

ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

functionedit2_Callback(hObject,eventdata,handles)

functionedit2_CreateFcn(hObject,eventdata,handles)

ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

functionedit3_Callback(hObject,eventdata,handles)

functionedit3_CreateFcn(hObject,eventdata,handles)

ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

functionpushbutton1_Callback(hObject,eventdata,handles)

handles.num1=strcat(get(handles.edit1,'string'),'+');

set(handles.edit1,'string',handles.num1);

guidata(hObject,handles);

functionpushbutton2_Callback(hObject,eventdata,handles)

handles.num2=strcat(get(handles.edit1,'string'),'-');

set(handles.edit1,'string',handles.num2);

guidata(hObject,handles);

functionpushbutton3_Callback(hObject,eventdata,handles)

handles.num3=strcat(get(handles.edit1,'string'),'*');

set(handles.edit1,'string',handles.num3);

guidata(hObject,handles);

functionpushbutton4_Callback(hObject,eventdata,handles)

handles.num4=strcat(get(handles.edit1,'string'),'/');

set(handles.edit1,'string',handles.num4);

guidata(hObject,handles);

functionpushbutton_1_Callback(hObject,eventdata,handles)

handles.shu1=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

ifhandles.yuanshu(end)=='N';

handles.yuanshu(end)='';

end

ifhandles.yuanshu

(1)=='0';

handles.yuanshu=handles.yuanshu(2:

end);

end

handles.shu1=strcat(handles.yuanshu,handles.shu1);

iflength(handles.shu1)<2;

elseif(length(handles.shu1)>=2)&&(handles.shu1(end-1)==')')&&(handles.shu1

(1)=='l')

temp=handles.shu1(end);

handles.shu1(end)=handles.shu1(end-1);

handles.shu1(end-1)=temp;

end

set(handles.edit1,'string',handles.shu1);

guidata(hObject,handles);

functionpushbutton_2_Callback(hObject,eventdata,handles)

handles.shu2=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

ifhandles.yuanshu(end)=='N';

handles.yuanshu(end)='';

end

ifhandles.yuanshu

(1)=='0';

handles.yuanshu=handles.yuanshu(2:

end);

end

handles.shu2=strcat(handles.yuanshu,handles.shu2);

iflength(handles.shu2)<2

;

elseif(length(handles.shu2)>=2)&&(handles.shu2(end-1)==')')&&(handles.shu2

(1)=='l')

temp=handles.shu2(end);

handles.shu2(end)=handles.shu2(end-1);

handles.shu2(end-1)=temp;

end

set(handles.edit1,'string',handles.shu2);

guidata(hObject,handles);

functionpushbutton_4_Callback(hObject,eventdata,handles)

handles.shu4=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

ifhandles.yuanshu(end)=='N';

handles.yuanshu(end)='';

end

ifhandles.yuanshu

(1)=='0';

handles.yuanshu=handles.yuanshu(2:

end);

end

handles.shu4=strcat(handles.yuanshu,handles.shu4);

iflength(handles.shu4)<2

;

elseif(length(handles.shu4)>=2)&&(handles.shu4(end-1)==')')&&(handles.shu4

(1)=='l')

temp=handles.shu4(end);

handles.shu4(end)=handles.shu4(end-1);

handles.shu4(end-1)=temp;

end

set(handles.edit1,'string',handles.shu4);

guidata(hObject,handles);

functionpushbutton_3_Callback(hObject,eventdata,handles)

handles.shu3=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

ifhandles.yuanshu(end)=='N';

handles.yuanshu(end)='';

end

ifhandles.yuanshu

(1)=='0';

handles.yuanshu=handles.yuanshu(2:

end);

end

handles.shu3=strcat(handles.yuanshu,handles.shu3);

iflength(handles.shu3)<2

;

elseif(length(handles.shu3)>=2)&&(handles.shu3(end-1)==')')&&(handles.shu3

(1)=='l')

temp=handles.shu3(end);

handles.shu3(end)=handles.shu3(end-1);

handles.shu3(end-1)=temp;

end

set(handles.edit1,'string',handles.shu3);

guidata(hObject,handles);

functionpushbutton_5_Callback(hObject,eventdata,handles)

handles.shu5=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

ifhandles.yuanshu(end)=='N';

handles.yuanshu(end)='';

end

ifhandles.yuanshu

(1)=='0';

handles.yuanshu=handles.yuanshu(2:

end);

end

handles.shu5=strcat(handles.yuanshu,handles.shu5);

iflength(handles.shu5)<2

;

elseif(length(handles.shu5)>=2)&&(handles.shu5(end-1)==')')&&(handles.shu5

(1)=='l')

temp=handles.shu5(end);

handles.shu5(end)=handles.shu5(end-1);

handles.shu5(end-1)=temp;

end

set(handles.edit1,'string',handles.shu5);

guidata(hObject,handles);

functionpushbutton_9_Callback(hObject,eventdata,handles)

handles.shu9=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

ifhandles.yuanshu(end)=='N';

handles.yuanshu(end)='';

end

ifhandles.yuanshu

(1)=='0';

handles.yuanshu=handles.yuanshu(2:

end);

end

handles.shu9=strcat(handles.yuanshu,handles.shu9);

iflength(handles.shu9)<2

;

elseif(length(handles.shu9)>=2)&&(handles.shu9(end-1)==')')&&(handles.shu9

(1)=='l')

temp=handles.shu9(end);

handles.shu9(end)=handles.shu9(end-1);

handles.shu9(end-1)=temp;

end

set(handles.edit1,'string',handles.shu9);

guidata(hObject,handles);

functionpushbutton_7_Callback(hObject,eventdata,handles)

handles.shu7=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

ifhandles.yuanshu(end)=='N';

handles.yuanshu(end)='';

end

ifhandles.yuanshu

(1)=='0';

handles.yuanshu=handles.yuanshu(2:

end);

end

handles.shu7=strcat(handles.yuanshu,handles.shu7);

iflength(handles.shu7)<2

;

elseif(length(handles.shu7)>=2)&&(handles.shu7(end-1)==')')&&(handles.shu7

(1)=='l')

temp=handles.shu7(end);

handles.shu7(end)=handles.shu7(end-1);

handles.shu7(end-1)=temp;

end

set(handles.edit1,'string',handles.shu7);

guidata(hObject,handles);

functionpushbutton_8_Callback(hObject,eventdata,handles)

handles.shu8=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

ifhandles.yuanshu(end)=='N';

handles.yuanshu(end)='';

end

ifhandles.yuanshu

(1)=='0';

handles.yuanshu=handles.yuanshu(2:

end);

end

handles.shu8=strcat(handles.yuanshu,handles.shu8);

iflength(handles.shu8)<2

;

elseif(length(handles.shu8)>=2)&&(handles.shu8(end-1)==')')&&(handles.shu8

(1)=='l')

temp=handles.shu8(end);

handles.shu8(end)=handles.shu8(end-1);

handles.shu8(end-1)=temp;

end

set(handles.edit1,'string',handles.shu8);

guidata(hObject,handles);

functionpushbutton_6_Callback(hObject,eventdata,handles)

handles.shu6=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

ifhandles.yuanshu(end)=='N';

handles.yuanshu(end)='';

end

ifhandles.yuanshu

(1)=='0';

handles.yuanshu=handles.yuanshu(2:

end);

end

handles.shu6=strcat(handles.yuanshu,handles.shu6);

iflength(handles.shu6)<2

;

elseif(length(handles.shu6)>=2)&&(handles.shu6(end-1)==')')&&(handles.shu6

(1)=='l')

temp=handles.shu6(end);

handles.shu6(end)=handles.shu6(end-1);

handles.shu6(end-1)=temp;

end

set(handles.edit1,'string',handles.shu6);

guidata(hObject,handles);

functionpushbutton18_Callback(hObject,eventdata,handles)

handles.jieguo=get(handles.edit1,'string');

handles.jieguo=strcat('=',handles.jieguo);

eval(['handles.result''1'handles.jieguo]);

set(handles.edit5,'string',num2str(handles.result1));

guidata(hObject,handles);

functionpushbutton_0_Callback(hObject,eventdata,handles)

handles.shu0=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

ifhandles.yuanshu(end)=='N';

handles.yuanshu(end)='';

end

ifhandles.yuanshu

(1)=='0';

handles.yuanshu=handles.yuanshu(2:

end);

end

handles.shu0=strcat(handles.yuanshu,handles.shu0);

iflength(handles.shu0)<2

;

elseif(length(handles.shu0)>=2)&&(handles.shu0(end-1)==')')&&(handles.shu0

(1)=='l')

temp=handles.shu0(end);

handles.shu0(end)=handles.shu0(end-1);

handles.shu0(end-1)=temp;

end

set(handles.edit1,'string',handles.shu0);

guidata(hObject,handles);

functionpushbutton20_Callback(hObject,eventdata,handles)

handles.shu10=get(hObject,'string');

handles.yuanshu=get(handles.edit1,'string');

handles.shu10=strcat(handles.yuanshu,handles.shu10);

set(handles.edit1,'string',handles.shu10);

guidata(hObject,handles);

functionpushbutton21_Callback(hObject,eventdata,handles)

functionedit5_Callback(hObject,eventdata,handles)

functionedit5_CreateFcn(hObject,eventdata,handles)

ifispc&&isequal(get(hObject,'BackgroundColor'),get(0,'defaultUicontrolBackgroundColor'))

set(hObject,'BackgroundColor','white');

end

functionpushbutton22_Callback(hObject,eventdata,handles)

handles.yuanshu=get(handles.edit1,'string');

handles.fanhao=strcat('-(',handles.yuanshu,')');

set(handles.edit1,'string',handles.fanhao);

guidata(hObject,handles);

functionpushbutton23_Callback(hObject,eventdata,handles)

set(handles.edit1,'string','0');

set(handles.edit5,'string','0');

guidata(hObject,handles);

functionpushbutton24_Callback(hObject,eventdata,handles)

result=questdlg('ÕæµÄÒªÍ˳ö£¿','Í˳öÈ·ÈÏ','È·¶¨','È¡Ïû','È¡Ïû');

ifresult=='È·¶¨',close(gcf);end

functionpushbutton25_C

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 医药卫生 > 预防医学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1