欢迎来到天天文库
浏览记录
ID:34627962
大小:675.73 KB
页数:34页
时间:2019-03-08
《Schlomer N. Guidelines for writing clean and fast code in MATLAB (en)(34s)》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、GuidelinesforwritingcleanandfastcodeinMATLAB®NicoSchlömer∗June3,2009ThisdocumentisaimedatMATLAB®beginnerswhoalreadyknowthesyntaxbutfeelarenotyetquiteexperiencedwithit.ItsgoalistogiveanumberofhintswhichenablethereadertowritequalityMATLAB®programsandtoavoidcommonlymademistakes.Therearethr
2、eemajorindependentchapterswhichmayverywellbereadseparately.Also,theindividualchapterseachsplitupintooneortwohandfulofchunksofinformation.Inthatsense,thisdocumentisreallyaslightlyextendedlistofdosanddon’ts.Chapter1describessomeaspectsofcleancode.Theimpactofasubsectionforthecleanlinessoft
3、hecodeisindicatedbyonetofiveÕ–symbols,wherefiveÕ’swanttosaythatfollowingthegivensuggestionisofgreatimportanceforthecomprehensibilityofthecode.Chapter2describeshowtospeedupthecodeandislargelyalistofmistakesthatbeginnersmaytendtomake.Thistime,theE-symbolrepresentstheamountofspeedthatyoucoul
4、dgainwhenstickingtothehintsgivenintherespectivesection.Thisguideiswrittenaspartofabasiccourseinnumericalanalysis,mostexamplesandcodeswillhencetendtorefertonumericalintegrationordifferentialequations.However,almostallaspectsareofgeneralnatureandwillalsobeofinteresttoanyoneusingMATLAB®.Con
5、tentsMATLAB®alternatives3GNUOctave.....................................3Scilab.........................................4∗UniversiteitAntwerpen,Middelheimlaan1,2020Antwerpen,Belgium.E-mail:nico.schloemer@ua.ac.be.11Codingclean5Multiplefunctionsperfile–ÕÕÕ.......................5Variablean
6、dfunctionnames–ÕÕÕ......................7Indentation–ÕÕÕÕ..............................9Linelength–Õ...................................10Spacesandalignment–ÕÕÕ..........................11Magicnumbers–ÕÕÕ.............................11Comments–ÕÕÕÕÕ............................12Usageofbr
7、ackets–ÕÕ..............................13Errorsandwarnings–ÕÕ............................13Switchstatements–ÕÕ.............................162Codingfast19Usingtheprofiler...................................19TheMATtrixLABoratory..............................19Matrixpre-allocation
此文档下载收益归作者所有