您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 公司方案 > MATLAB仿XP系统计算器编程代码和GUI附图
MATLAB仿XP系统计算器编程代码和GUI附图functionvarargout=Caculater(varargin)%CACULATERM-fileforCaculater.fig%CACULATER,byitself,createsanewCACULATERorraisestheexisting%singleton*.%%H=CACULATERreturnsthehandletoanewCACULATERorthehandleto%theexistingsingleton*.%%CACULATER('CALLBACK',hObject,eventData,handles,...)callsthelocal%functionnamedCALLBACKinCACULATER.Mwiththegiveninputarguments.%%CACULATER('Property','Value',...)createsanewCACULATERorraisesthe%existingsingleton*.Startingfromtheleft,propertyvaluepairsare%appliedtotheGUIbeforeCaculater_OpeningFunctiongetscalled.An%unrecognizedpropertynameorinvalidvaluemakespropertyapplication%stop.AllinputsarepassedtoCaculater_OpeningFcnviavarargin.%%*SeeGUIOptionsonGUIDE'sToolsmenu.ChooseGUIallowsonlyone%instancetorun(singleton).%%Seealso:GUIDE,GUIDATA,GUIHANDLES%EdittheabovetexttomodifytheresponsetohelpCaculater%LastModifiedbyGUIDEv2.519-Jul-201113:59:25%Begininitializationcode-DONOTEDIT%程序有由于使用num2str函数,是的小数最多为四位,如需更多,可参考num2str(X,N),其中N表示最大容许小数位数gui_Singleton=1;gui_State=struct('gui_Name',mfilename,...'gui_Singleton',gui_Singleton,...'gui_OpeningFcn',@Caculater_OpeningFcn,...'gui_OutputFcn',@Caculater_OutputFcn,...'gui_LayoutFcn',[],...'gui_Callback',[]);ifnargin&&ischar(varargin{1})gui_State.gui_Callback=str2func(varargin{1});endifnargout[varargout{1:nargout}]=gui_mainfcn(gui_State,varargin{:});elsegui_mainfcn(gui_State,varargin{:});end%Endinitializationcode-DONOTEDIT%---ExecutesjustbeforeCaculaterismadevisible.functionCaculater_OpeningFcn(hObject,eventdata,handles,varargin)%Thisfunctionhasnooutputargs,seeOutputFcn.%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%varargincommandlineargumentstoCaculater(seeVARARGIN)%ChoosedefaultcommandlineoutputforCaculaterhandles.output=hObject;%Updatehandlesstructureguidata(hObject,handles);%UIWAITmakesCaculaterwaitforuserresponse(seeUIRESUME)%uiwait(handles.fig_caculater);set(handles.edit_show,'String','0','UserData',0);set(handles.pushbutton_n0,'UserData',0);set(handles.pushbutton_n1,'UserData',0);set(handles.pushbutton_n2,'UserData',0);set(handles.pushbutton_n3,'UserData',0);set(handles.pushbutton_plus,'UserData',0);set(handles.pushbutton_M,'UserData',0);set(handles.pushbutton_MM,'Enable','off','String','','UserData',0);set(handles.pushbutton_point,'UserData',0);set(handles.pushbutton_negate,'UserData',0);set(handles.pushbutton_sqrt,'UserData',0);%---Outputsfromthisfunctionarereturnedtothecommandline.functionvarargout=Caculater_OutputFcn(hObject,eventdata,handles)%varargoutcellarrayforreturningoutputargs(seeVARARGOUT);%hObjecthandletofigure%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)%Getdefaultcommandlineoutputfromhandlesstructurevarargout{1}=handles.output;%---Executesonbuttonpressinpushbutton_MC.functionpushbutton_MC_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton_MC(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)num=get(handles.pushbutton_MM,'UserData',0);if(rem(num,2)==1)set(handles.pushbutton_M,'UserData',0);if(get(handles.pushbutton_n2,'UserData')==0)&&(get(handles.pushbutton_n3,'UserData')==0)set(handles.pushbutton_n0,'UserData',0);elseif(get(handles.pushbutton_n2,'UserData')==1)&&(get(handles.pushbutton_n3,'UserData')==0)set(handles.pushbutton_n1,'UserData',0);endset(handles.edit_show,'String','0','UserData',0);endset(handles.pushbutton_point,'UserData',0);set(handles.pushbutton_negate,'UserData',0);set(handles.pushbutton_sqrt,'UserData',0);%---Executesonbuttonpressinpushbutton_MR.functionpushbutton_MR_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton_MR(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)num=get(handles.pushbutton_MM,'UserData');if(rem(num,2)==1)num1=get(handles.pushbutton_M,'UserData');set(handles.edit_show,'String',num2str(num1),'UserData',num1);if(get(handles.pushbutton_n2,'UserData')==0)&&(get(handles.pushbutton_n3,'UserData')==0)set(handles.pushbutton_n0,'UserData',num1);elseif(get(handles.pushbutton_n2,'UserData')==1)&&(get(handles.pushbutton_n3,'UserData')==0)set(handles.pushbutton_n1,'UserData',num1);endendset(handles.pushbutton_point,'UserData',0);set(handles.pushbutton_negate,'UserData',0);set(handles.pushbutton_sqrt,'UserData',0);%---Executesonbuttonpressinpushbutton_MS.functionpushbutton_MS_Callback(hObject,eventdata,handles)%hObjecthandletopushbutton_MS(seeGCBO)%eventdatareserved-tobedefinedinafutureversionofMATLAB%handlesstructurewithhandlesanduserdata(seeGUIDATA)num=get(handles.pushbutton_MM,'UserData');if(rem(num,2)==1)str=get(handles.edit_show,'String');set(handles.pushbutton_M,'UserData',str2num(str));endset(handles.pushbutton_point,'UserData',0);set(handles.pushbutton_negate,'UserData',0);set(handles.pushbutton_sqrt,'UserData',0);%---Executesonbuttonpressinpushbutton_M.functionpushbutton_M_Callback(hObject,eve
本文标题:MATLAB仿XP系统计算器编程代码和GUI附图
链接地址:https://www.777doc.com/doc-4234559 .html