1. 首页
  2. 编程语言
  3. 其他
  4. programming tips

programming tips

上传者: 2018-12-25 14:57:29上传 PDF文件 446.48KB 热度 57次
本书系统地介绍了matlab编程的入门知识,通过本书的学习,即能够学习matlab编程的基础知识,又是学习matlab英语的较好教材,为进一步学习matlab的人打下一个坚实的英文基础。Revision HistoryJuly 2002Online onlyNew for MaTLAB 6.5 ( Release 13)June 2004Online onlyRevised for MATLAB 7.0(Release 14)March 2005Online onlyRevised for MaTLAB7.0.4(Release 14SP2)September 2005 Online onlyRevised for Matlab 7. 1(Release 14SP3)September 2007 Online onlyRereleased for Version 7.5 Release 2007b)March 2008Online onlyRereleased for Version 7.6 Release 2008October2008 Online onlyRereleased for Version 7.7(Release 2008b)ContentsProgramming TipsIntroduction1-2Command and Function Syntax ........... 1-3yntax Help1-3Command and Function SyntaxesCommand line continuationCompleting commands using the tab Key....... 1-4Recalling commandsClearing CommandsSuppressing output to the ScreenHelp1-6Using the Help browser1-6Help on Functions from the Help browserHelp on Functions from the Command WindowTopical helpPaged OutputWriting your Own HelpHelp for Subfunctions and Private functions1-9Help for Methods and Overloaded FunctionsDevelopment Environment1-11Workspace browserUsing the Find and Replace utility1-11Commenting Out a block of Code,1-12Creating M-Files from Command History ....... 1-12Editing M-Files in EMACs1-12M-File functions1-13M-File structure1-13Using Lowercase for Function Names,1-13Getting a Functions Name and Path1-14What M-Files does a function Use?1-14Dependent functions, Built-Ins, Classes15Function Arguments1-16Getting the Input and output arguments1-16Variable Numbers of Arguments1-16String or Numeric Arguments1-17Passing Arguments in a Structure1-17Passing arguments in a Cell array1-18Program Development1-19Planning the Program1-19Using Pseudo-Code1-19Selecting the right Data Structures ......... 1-19General Coding practices,1-20Naming a Function Uniquely1-20The Importance of comments1-20Coding in Steps1-21Making modifications in Steps1-21Functions with One calling Function ......... 1-21Testing the Final program,1-21Debugging1-22The MatlAB Debug functions1-22More debug functions1-22The MatLAB Graphical Debugger1-23a Quick Way to Examine variables1-23Setting breakpoints from the Command Line ..... 1-24Finding line numbers to set breakpoints1-24Stopping Execution on an Error or Warning ...... 1-24Locating an Error from the error message ....... 1-24Using Warnings to Help debug1-25Making Code execution Visible··1-25Debugging Scripts1-25Variables1-26Rules for variable names1-26Making Sure variable Names Are valid,,,,,,,,1-26Do Not use function names for variables.,1-27Checking for Resd Keywords1-27Avoid Using i andj for Variables,,,,,,,,,,1-28Avoid overwriting variables in Scripts1-28Persistent variabl1-28Protecting Persistent variables,1-28Global variables1-29ContentStrings1-30Creating Strings with Concatenation1-30Comparing Methods of Concatenation1-30Store Arrays of Strings in a Cell array1-31Converting between Strings and cell arrays1-31Search and replace using regular Expressions ..... 1-31Evaluating Expressions1-33Find alternatives to Using eval1-33assigning to a Series of Variables1-33Short-Circuit Logical Operators1-34Changing the Counter Variable within a for Loop1-34MATLAB Path1-35Precedence rules1-35File precedence1-36Adding a directory to the Search Path1-36Handles to functions not on the path1-36Making toolbox File changes visible to MaTLaB.... 1-37Making nontoolbox File changes visible to MATLAB1-38Change Notification on Windows1-38Program Control1-39Using break, continue, and return1-39Using switch Versus if1-40MATLAB case Evaluates Strings .........1-40Multiple conditions in a case statement1-40Catching Errors with try-a∵,∵·..,.,..,Implicit Break in switch-case1-40Variable Scope in a switch1-411-41Nested try-catch Blocks1-42Forcing an Early return from a Function1-42Saⅴ e and load...,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,1-43Saving data from the Workspace1-43Loading data into the Workspace1-43Viewing variables in a MaT-File1-44Appending to a mat-file1-44Save and load on startup or quitSaving to an ascii File1-45Files and filenames1-46Naming M-files1-46Naming Other Files1-46Passing Filenames as arguments1-47Passing filenames to AscII Files1-47Determining Filenames at Run-Time1-47Returning the Size of a File1-47Input/Output .....1-49File io function overview1-49Common io Functions1-49Readable file formats1-50Using the Import wizard,1-50Loading mixed Format Data1-50Reading Files with Different Formats1-51Reading ascii Data into a Cell array1-51Interactive Input into Your Program1-51Starting MATLAB1-52Getting matlab to Start Up Faster1-52Operating System Compatibility1-53Executing O/S Commands from MAtLAB1-53Searching Text with grep ......,1-53Constructing Paths and Filenames .......... 1-53Finding the matlab root directory1-54Temporary Directories and Filenames1-54Demos1-55Demos available with matLaB1-55For more information1-56Current CSsm1-56Archived cssm1-56MATLAB Technical Support,1-56Tech notes,,,,,,,,,,,,,,,,,,,,,1-56MATLAB Central1-56MATLAB Newsletters(Digest, News notes)1-56MATLAB Documentation1-57MATLAB Index of Examples春鲁垂章垂1-57ContentsProgramming TipsIntroduction"on page 1-2·“ Command and Function Syntax” on page1-3Help” on page1-6Development Environment"on page 1-11M-File Functions"on page 1-13·“ Function Arguments” on page1-16Program Development"on page 1-19Debugging,on page 1-22Variables"on page 1-26Strings” on page130Evaluating Expressions"on page 1-33MATLAB Path"on page 1-35Program Control on page 1-39·“ Save and load” on page1-43Files and Filenames"on page 1-46Input/Output"on page 1-49Starting MatLAB"on page 1-52."Operating System Compatibility"on page 1-53Demos” on page1-55For More Information"on page 1-56Programming lipsntroductionThis section is a categorized compilation of tips for the matlabprogrammer. Each item is relatively brief to help you browse through themand find information that is useful. Many of the tips include a reference tospecific matlaB documentation that gives you more complete coverage ofthe topic. You can find information on the following topicsFor suggestions on how to improve the performance of your MatlaBprograms, and how to write programs that use memory more efficiently, seeImproving Performance and Memory Usage
用户评论