资源描述:
《Intro to Matlab》由会员上传分享,免费在线阅读,更多相关内容在学术论文-天天文库。
1、Chapter1IntroductiontoMATLABThisbookisanintroductiontotwosubjects:Matlabandnumericalcomputing.This¯rstchapterintroducesMatlabbypresentingseveralprogramsthatinves-tigateelementary,butinteresting,mathematicalproblems.Ifyoualreadyhavesomeexperienceprogram
2、minginanotherlanguage,wehopethatyoucanseehowMatlabworksbysimplystudyingtheseprograms.Ifyouwantamorecomprehensiveintroduction,anon-linemanualfromTheMathWorksisavailable.SelectHelpinthetoolbaratoptheMatlabcommandwindow,thenselectMATLABHelpandGettingStart
3、ed.APDFversionisavailableunderPrintableversions.ThedocumentisalsoavailablefromTheMathWorksWebsite[10].ManyothermanualsproducedbyTheMathWorksareavailableonlineandfromtheWebsite.Alistofover600Matlab-basedbooksbyotherauthorsandpublishers,insev-erallanguag
4、es,isavailableat[11].ThreeintroductionstoMatlabareofparticularinteresthere:arelativelyshortprimerbySigmonandDavis[8],amedium-sized,mathematicallyorientedtextbyHighamandHigham[3],andalarge,comprehen-sivemanualbyHanselmanandLittle¯eld[2].Youshouldhaveaco
5、pyofMatlabcloseathandsoyoucanrunoursampleprogramsasyoureadaboutthem.Alloftheprogramsusedinthisbookhavebeencollectedinadirectory(orfolder)namedNCM(Thedirectorynameistheinitialsofthebooktitle.)YoucaneitherstartMatlabinthisdirectoryorusepathtooltoaddthedi
6、rectorytotheMatlabpath.February15,200812Chapter1.IntroductiontoMATLAB1.1TheGoldenRatioWhatistheworld'smostinterestingnumber?Perhapsyoulike¼,ore,or17.SomepeoplemightvoteforÁ,thegoldenratio,computedherebyour¯rstMatlabstatement.phi=(1+sqrt(5))/2Thisproduc
7、esphi=1.6180Let'sseemoredigits.formatlongphiphi=1.61803398874989Thisdidn'trecomputeÁ,itjustdisplayed15signi¯cantdigitsinsteadof5.Thegoldenratioshowsupinmanyplacesinmathematics;we'llseeseveralinthisbook.Thegoldenratiogetsitsnamefromthegoldenrectangle,sh
8、owninFigure1.1.Thegoldenrectanglehasthepropertythatremovingasquareleavesasmallerrectanglewiththesameshape.f11f−1Figure1.1.Thegoldenrectangle.Equatingtheaspectratiosoftherectanglesgivesade¯ningequationforÁ:1Á¡1=:Á1Thisequationsaysthatyou