IntroductiontoMATLABMATLAB(shortforMatrixLaboratory)isaspecial-purposecomputerprogramoptimizedtoperformengineeringandscientificcalculations.Itstartedlifehasaprogramdesignedtoperformmatrixmathematics,butovertheyearsithasgrownintoaflexiblecomputingsystemcapableofsolvingessentiallyanytechnicalproblem.TheMATLABprogramimplementstheMATLABprogramminglanguageandprovidesanextensivelibraryofpredefinedfunctionsthatmaketechnicalprogrammingtaskseasierandmoreefficient.ThisbookintroducestheMATLABlanguageandshowshowtouseittosolvetypicaltechnicalproblems.MATLABisahugeprogram,withanincrediblyrichvarietyoffunctions.EventhebasicversionofMATLABwithoutanytoolkitsismuchricherthanothertechnicalprogramminglanguages.Therearemorethan1000functionsinthebasicMATLABproductalone,andthetoolkitsextendthiscapabilitywithmanymorefunctionsinvariousspecialties.ThisbookmakesnoattempttointroducetheusertoallofMALTLAB′sowntoolstolocatethecorrectfunctionforaspecificpurposefromtheenormouschoiceavailable.AdvantagesofMATLABMATLABhasmanyadvantagescomparedwithconventionalcomputerlanguagesfortechnicalproblemsolving.Amongthemarethefollowing:1.EaseofUseMATLABisaninterpretedlanguage,likemanyversionsofBasic.LikeBasic,itisveryeasytouse.Theprogramcanbeusedasascratchpadtoevaluateexpressionstypedatthecommandline,oritcanbeusedtoexecutelargeprewrittenprograms.Programsmaybeeasilywrittenandmodifiedwiththebuilt-inintegrateddevelopmentenvironment,anddebuggedwiththeMATLABdebugger.Becausethelanguageissoeasytouse,itisidealforeducationaluse,andfortherapidprototypingofnewprograms.Manyprogramdevelopmenttoolsareprovidedtomaketheprogrameasytouse.aworkspacebrowser,andextensivedemos.2.PlatformindependenceMATLABissupportedonmanydifferentcomputersystems,providingalargemeasureofplatformindependence.Atthetimeofthiswriting,thelanguageissupportedonwindows9x/NT/2000andmanydifferentversionsofUNIX.Programswrittenonanyplatformwillrunonalloftheotherplatforms,anddatafileswrittenonanyplatformmaybereadtransparentlyonanyotherplatforms,ASaresult,ProgramswritteninMATLABcanmigratetonewplatformswhentheneedsoftheuserchange.3.PredefinedFunctionsMATLABcomescompletewithanextensivelibraryofpredefinedfunctionsthatprovidetestedandprepackagedsolutionstomanybasictechnicaltasks.Forexample,supposethatyouarewritingaprogramthatmustcalculatethestatisticsassociatedwithaninputdataset.Inmostlanguages,youwouldneedtowriteyourownsubroutinesorfunctionstoimplementcalculationssuchasthearithmeticmean,standarddeviation,median,andsoforth.TheseandhundredsofotherfunctionsarebuiltrightintotheMATLABlanguage,makingyourjobmucheasier.InadditiontothelargelibraryoffunctionsbuiltintothebasicMATLABlanguage,manyspecial-purposetoolboxesareavailabletohelpsolvecomplexproblemsinspecificareas.Forexample,ausercanbuystandardtoolboxestosolveproblemsinSignalProcessing,ControlSystems,Communications,ImageProcessing,andNeuralNetworks,amongmanyothers.Thereisalsoanextensivecollectionoffreeuser-contributedMATLABprogramsthataresharedthroughtheMATLABWebsite.4.Device-IndependentPlottingUnlikemostothercomputerlanguages,MATLABhasmanyintegralplottingandimagingcommands.TheplotsandimagescanbedisplayedonanygraphicaloutputdevicesupportedbythecomputeronwhichMATLABisrunning.ThiscapabilitymakesMATLABanoutstandingtoolforvisualizingtechnicaldata.5.GraphicalUserInterfaceMATLABincludestoolsthatallowaprogrammertointeractivelyconstructagraphicaluserinterface(GUI)forhisorherprogram.Withthiscapability,theprogrammercandesignsophisticateddataanalysisprogramsthatcanbeoperatedbyrelativelyinexperiencedusers.6.MATLABCompilerMATLAB′sflexibilityandplatformindependenceisachievedbycompilingMATLABprogramsintoadevice-independencep-code,andtheninterpretingthep-codeinstructionsatruntime.ThisapproachissimilartothatusedbyMicrosoftisVisualBasiclanguage.Unfortunately,theresultingprogramscansometimesexecuteslowlybecausetheMATLABcodeisinterpretedratherthancompiled.Wewillpointoutfeaturesthattendtoslowprogramexecutionwhenweencounterthem.AseparateMATLABcompilerisavailable.ThiscompilercancompileaMATLABprogramintoatrueexecutablethatrunsfasterthantheinterpretedcode.ItisagreatwaytoconvertaprototypeMATLABprogramintoanexecutablesuitableforsaleanddistributiontousers.DisadvantagesofMATLABMATLABhastwoprincipaldisadvantages.Thefirstisthatitisaninterpretedlanguage,andthereforecanexecutemoreslowlythancompiledlanguages.ThisproblemcanbemitigatedbyproperlystructuringtheMATLABprogramandbytheuseoftheMATLABcompilertocompilethefinalMATLABprogrambeforedistributionandgeneraluse.Theseconddisadvantageiscost:AfullcopyofMATLABis5to10timesmoreexpensivethanaconventionalCorFortrancompiler.Thisrelativelyhighcostismorethanoffsetbythereducedtimerequiredforanengineerorscientisttocreateaworkingprogram,soMATLABiscost-effectiveforbusinesses.However,itistooexpensiveformostindividualstoconsiderpurchasing.Fortunately,thereisalsoaninexpensiveStudentEditionofMATLAB,whichisagreattoolforstudentswantingtolearnthelanguage.TheStudentEditionofMATLABisessentiallyidenticaltothefulledition.Withtheintroductionofbranchesandloops,ourprogramsare