还剩15页未读,继续阅读
本资源只提供10页预览,全部文档请下载后查看!喜欢就下载吧,查找使用更方便
文本内容:
课程设计报告matlab题目简易计算器的设计学院电子信息工程学院专业电子信息学生姓名和学号________________________________指导教师%ha n die s s tru c t ure w ith handle s an d u s er da t a see GUIDATA tex tst ring二geth and1es t e xtl,7str i ng;ot e xts t r i ng=st r c a tt e xts t ring,;s et ha n d les te x tl,stri n g,textst r ingo%----------Execut e s on butt o n pre s s in pO.function pO_C allbackhO b jec t,event d at a,handles%h Object h a ndle t o p0see GCBO%e ven t d a ta reserved—to be defin e d in a f u tur e versi o n of MATLAB%hand1es s tr uc tu r e with han dies a n d us e r data s e e GUIDATAtexts tri n g=get h a n d1e s t extl,string;otex t st r ing二strcatt extstring,O;set handle s.textl,s tr i ng5,textst ring%----------E xecut e s o n butto n pre ss in sub.f un c tions ub_Cal1back hO b j e c t,even td a ta,handles%hO b ject han die tosu bs eeGCB0%ev e n t data res e rv e d-to be d e f i n e d i n a f u ture vers i on of MATLAB%handle s struct u re with handl e s and user data see GUIDATA t extstring=gethandleso te x tl,s tri n g;te x ts tring=strc at textstring,;seth and1e s te x t1,string,otex tst ring%------------E xecutes on button pres si n div.f unctio nd i v_Cal1back h0bject,ev en td a ta,h andles%hO bject ha n die t o d i vs eeGCBO%e ventd a ta re s e rv ed一t ob e d efined in a future versio nof MATLAB%h a nd le s structure wi th h and1e s and us er dat as eeGUIDATAt exts tr ing=g e t h a ndles textl,st r i ng;otex tstring=s trcat textstring,/;set han d1e s t ext1,str i n g,text s t ringo%----------Exec uteso n b u tton p r essi n mulofunctionmul_Callbac k hOb j e c t,ev entdata,han dies%hObjec t han dle tomu1see GCBO%even tdat a rese r ved-t obe def ine d in a fu tu re v ersio n of MATLAB%hand1e ss tru c t ure wit h h an dies and user data see GUIDATAtexts tr i n g=g e th andie s.textl,str i n gJ;t extst r i n g=s trcat t e xtst ring,*;se t handlestextl,s t ring,texts tr ingExecutes o nb u tton press in d engha ofunction den ghao_C al1ba ckohO b j ect,eventda t a,h an dl e s%h Object han dle t o den g haosee GCBO%eve ntda ta re s e rve d一to be d e f in e d in a fut ur e v e rsi o no fMAT LAB%han dies structure withhan dies and use rda t a see GUID ATAtexts tr i n g=get handlesot ext1,7string7;te x ts t ring=ev a1textst r i ng;s eth a nd1es.te x tl,s t ring5,textstrin g%------------Exec utes on button pr essi n c1ea rofu n ction c1ear_CalIba ckh0bj e ct,eve ntdata,ha ndie s%hOb j ect h andle t o clea r se eGC B0%eve nt data re s erved—to b e d ef i ned in a future v er si o nof MATLAB%handles st rue turewi thha nd les andus er datase eGUIDATAs eth andle s.tex t1,strin g,07f un c tion ex i t C a11back hObject,even tdata,han dies%h O bje c t handl et o exitsee GCBO%even tdata r e s e rved-to bed efined in a f u ture versi on of MATLAB%han diesstruc tur ewithhandl e s and userd at as eeGUIDATAclose gc ffun ctionc a1culate_Call b a ck hOb j e c t,eventd ata,handles%h Obje c t handle toc alc u1a te see GCBO%eve n tda ta rese rved—t obe define din a futu r e v e rsion ofM ATLAB%h and1e sstructure wit h handles and user datas eeGU I DATAtexts tr i ng=g eth andle s.tex t1,s tring;te x tstr i ng=ev a1t exts tr ing;seth andles.textl,string’,texts trin g%---------------E xecu t esonbut t on press in po int.f unct ion point_Cal1back h0bje c t,e ven tda ta,handle s%hO b ject handl e to point see GCBO%eve ntdata reserv ed-to bed e fine din a f utur e ver s ion of MATLAB%han diess tructure withha n dies and us erdat as eeGUIDATA texts tri ng=get h and1es tex t1,stri ng;ot exts tring二strc att extstring,;seth and1es textl,string,t extst r ingo设计功能
1.可进行加减乘除四则运算
2.可进行清零,退出等
三、界面设计及运行结果❽OO Calculator.fig.or OOCalculatorexit-Calculator93Calculatorexh5*8exitr-Calculator401-3简单的实例测试O
五、心得及体会通过这次matlab课程设计,让我对mat lab有了更深的了解.Ma tlab不仅给我们更方便的编程体验,其中强大的数值运算,信号处理等功能更是我们专业实现相关系统设计的好工具00000
一、选题目的及意义GUI的广泛应用是当今计算机发展的重大成就之一,它极大地方便了非专业用户的使用人们从此不再需要死记硬背大量的命令,取而代之的是可以通过窗口、菜单、按键等方式来方便地进行操作,而在matlab有很简单的gu i设计工具,我们可以通过这个工具轻松地构建我们想要的程序,从而实现与用户的信息交互本次课程设计是使用了mat lab中的gu ide生成了简单的计算器程序
二、源代码f uncti on varar g out=Calculator vara rgin%Simpl eCal c u1a tor%@Anh ui Un iv ersit y%Begin initializa tion code-DO NOTEDI Tgui_Singl et on=1;g uiS tate=s truet Cgui_Name,mf ilen a me,g uiSingleton,gui_Sing1eton,gui_OpeningF cn,@Calcul at or0p eningg ui Out put F cn,@Calculat orOutputFcn,...f gui_L ayoutFcn,[],,gui_Callback,[];i f nar ginis char va rargin{1}g ui_St ate g ui C all ba ck=str2funcvarargin{1};en doifna rgo u t[v arargout{1narg o ut}]=gui_ma infcn gui_State,varargin{:};elseg ui mainfen gui_S tate,vara rgin{:};end%End ini tia1i zati onc ode—DO NOTE DIT%------------Execu t esjust beforeCalculate ris made v isib le.fu nction Calc u latorOp en ing Fenh Obje c t,ev entdata,hand1es,v ara rgin%T hi sfunc tion hasno outp u tar gs,se eOut pu tFcn.%h0bj ecth and1eto figure%eve ntdata reserved-to bede fin edin a future versi onof MATLA B%handles st ructur ewithh a ndl esand user data see GUIDA TA%v arargin command line argu ments toCalc ulator see VARARGIN%Choo sedefault c ommandlineoutput forCalcul at orhandlesoout put=hObj ect;%U pd ateh andles structu reguid ata hObject,h andles;%U IWAIT makesC a1cula tor wa itfor user responsesee UIRESUME%u iwait handleso fi g urel;%-----------0utputs from thisfun ction areretu rned toth ecommandlinef unotion var argout=C a1cu1ato r_0utpu tFc nh0bject,eve n tdata,handle s%vara rgoutcell arrayf orretu rni ng ou tputarg ssee VARARGOUT;%hO bject hand1e tofigure%even tdatares erv ed一tobed efinedinafutu re version of MATLAB%ha n diesstruct urewith handlesand userdata seeG UIDATA%Get defa ultcomm and1ineoutput fromhandles struc turevarargout{1}=handles.output;%--------Execute s onb ut ton press in pl.func tion pl_Ca1lb ack hObject,e vent d ata,ha nd1es%hObj e cth andle to p1se eGCBO%eventdatar eserved-to bedef inedinafut ure ve rsi onof MATLAB%handles str ucture withha n dlesand userdata seeGU IDATAtex tst ring=ge than d les.textl,str ing;te x tst r ing=strca tt extstring,1;s ethandlesot ext1,string5,textstring%------------Ex ecu teson but ton press in p2ofunction p2_C allback h Object,e ventdata,hand1es%h Objecthandle to p2see GCBO%even td ata reserved—to bed efinedinaf uture vers i onofMATLAB%h andles stru c ture withhandle sand userdataseeGUID ATAtextstring=g ethand1es t ex tl,s tring;ot extst ring=strcatt ext stri ng,2;set handles,t ex tl,str ing,te xtstring%--------------Execu t eson butt onpres sinp3ofu nction p3_Callback hObj ect,even tdata,handles%h0bjecthandle to p3see%even tdata GCBOreserved-to bedefinedinafut ure versionofMATL AB%handles st r ucturewithha ndlesanduserdatasee GUIDATAtextstring=get han dles.te xt1,string;textst ring=str cattex tstrin g,3;set han dles.t extl,string,t extstring%----------E xecutesonbu ttonpres sinp4ofun ctionp4_Cal1back hObject,e ventdata,hand les%h Objecthan dletop4se eG CB O%eventdatareserved-to bede finedinafu tureversion of MATLAB%handle sstructure withh and1esandus erdata seeGUIDATAt extstring=g etha n dies,t extl,stri ng;te xtstring=strcatt extstr ing,74;s ethandleso text1,st ring,t extstr ing%------------E xecut esonbutt onpressinp5function p5—Ca1Ibac khObject,eventda ta,handles%h0bjecthandie top5se eGCBO%eventd atareser ved-tobe definedinaf uture version ofMATLAB%ha ndlesstru cturewith handle sand userdata seeGUI DATAt extstr ing=get handies,text1,string;textstring=strc at text s tring,5;se th andles textl,string,te xt stringo%----------Executes onbut t onpr essinp6ofunc tion p6_CallbackhObject,eventdata,handies%hObjec thand1e top6seeGCBO%ev entda tareserved-tobe def inedinafutureve rsi onofMATLAB%h andlesstructurew ithh andlesanduserdatasee GUIDATAtextstring=get han dlest ext1,string,;otextst ring=strcat textstring,6;set handlestextl,string,textstrin go%--------Exe cu teson buttonpress inp
7.funct ionp7_Ca1lb ackh Object,even tdata,handles%hO bjecthand1e top7see GCBO%e ventdatarese r ved—to be defi nedina futureversi onofMATLAB%handles structurew ithhandlesanduserdataseeGUIDATAtextstring=g ethand1estextl,string;otext string=str cattextstring,7;sethan dles.t ext1,string,texts tringExe cutesonbut tonpress inp
8.fu nction p8Ca11backhObjec%hObject eventdata,hand1eshan dietop8seeGC BO%even tdatareserved-to bedefinedinafutureversionofMATLAB%handlesstructure withhand1esand userdataseeGUIDATAtexts tring=get handles.text1,stri ng;te xtstring=s treattextstring,8;set hand1estex t1,string,textstr ing%----------E xecutesonbut tonpress inp
9.functionp9_Ca1IbackhObject,event data,han dies%hObject handletop9see GCBO%eventdata reserved—to bede fined inafutureversionofMATLAB%handie sstructure withhandiesanduserdataseeGUIDATAtextst ring=g ethand1estextl,s tring;tex ts tring=strcattextstring,9;se thandle Sotextl,rstring,textstring%----------E xecutesonbuttonpr essinadd.functi onadd_CalIbackh Object,ev entdat a,hand1es%hObject handletoadd seeGCBO%even tdata reserved ofMATLABto bedefined ina futureversion。
个人认证
优秀文档
获得点赞 0