Using MATLAB (779505), страница 2
Текст из файла (страница 2)
4-33Workspace, Search Path, and File Operations5MATLAB Workspace . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3Workspace Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-3Viewing and Editing Workspace VariablesUsing the Array Editor . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . 5-10Search Path . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14How the Search Path Works . . . . . . . . . . . . . . . . . . . . . . . . . . . 5-14Viewing and Setting the Search Path . . . . . . . . . . . . . . .
. . . . . 5-15File Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Current Directory Field . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Current Directory Browser . . . . . . . . . . . . . . . . . . . .
. . . . . . . .Viewing and Making Changes to Directories . . . . . . . . . . . . . .Creating, Renaming, Copying, andRemoving Directories and Files . . . . . . . . . . . . . . . . . . . . . . . .Opening, Running, and Viewing the Content of Files . . . . . . .Finding and Replacing Content Within Files . . . . . . . . . . . . . .Preferences for the Current Directory Browser . . . . .
. . . . . . .5-205-205-205-225-235-265-285-30Importing and Exporting Data6Importing Text Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-4Using the Import Wizard with Text Data . . . . . . . . . . . . . . . . . 6-4Using Import Functions with Text Data . . . . . . . . . . . . .
. . . . . 6-9Importing Numeric Text Data . . . . . . . . . . . . . . . . . . . . . . . . . . 6-11Importing Delimited ASCII Data Files . . . . . . . . . . . . . . . . . . . 6-12Importing Numeric Data with Text Headers . . . . . . . . .
. . . . . 6-13ivContentsImporting Mixed Alphabetic and Numeric Data . . . . . . . . . . . 6-14Exporting ASCII Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-16Exporting Delimited ASCII Data Files . . . . . . . . . . . .
. . . . . . . 6-17Using the diary Command to Export Data . . . . . . . . . . . . . . . . 6-18Importing Binary Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-20Using the Import Wizard with Binary Data Files . . . . . . . . . . 6-20Using Import Functions with Binary Data . . . . . . . . . . .
. . . . 6-22Exporting Binary Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6-25Exporting MATLAB Graphs in AVI Format . . . . . . . . . . . . . . 6-27Working with HDF Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Overview of MATLAB HDF Support . . . .
. . . . . . . . . . . . . . . .MATLAB HDF Function Calling Conventions . . . . . . . . . . . . .Importing HDF Data into the MATLAB Workspace . . . . . . . .Exporting MATLAB Data in an HDF File . . . . . . . . . . . . . . . .Including Metadata in an HDF File . . . . . . . . . . . . . . . . . . . . .Using the MATLAB HDF Utility API . .
. . . . . . . . . . . . . . . . . .6-296-306-316-336-416-476-49Using Low-Level File I/O Functions . . . . . . . . . . . . . . . . . . . .Opening Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Reading Binary Data . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Writing Binary Data . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Controlling Position in a File . . . . . . . . . . . . . . . . . . . . . . . . . .Reading Strings Line-By-Line from Text Files . . . . . . . . . . .
.Reading Formatted ASCII Data . . . . . . . . . . . . . . . . . . . . . . . .Writing Formatted Text Files . . . . . . . . . . . . . . . . . . . . . . . . . .Closing a File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6-516-526-546-556-566-586-596-616-62Editing and Debugging M-Files7Starting the Editor/Debugger .
. . . . . . . . . . . . . . . . . . . . . . . . . 7-3Creating a New M-File in the Editor/Debugger . . . . . . . . . . . . . 7-4Opening Existing M-Files in the Editor/Debugger . . . . . . . . . . 7-5vOpening the Editor Without Starting MATLAB . . . . . . . . . . . . 7-6Closing the Editor/Debugger . . . . . . . .
. . . . . . . . . . . . . . . . . . . . 7-6Creating and Editing M-Files with the Editor/Debugger . . 7-8Appearance of an M-File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-8Navigating in an M-File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-11Saving M-Files . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-15Running M-Files from the Editor/Debugger . . . . . . . . . . . . . . . 7-15Printing an M-File . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . 7-16Closing M-Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7-16Debugging M-Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Types of Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Finding Errors . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . .Debugging Example – The Collatz Problem . . . . . . . . . . . . . . .Using Debugging Features . . . . . . . . . . . . . . . . . . . . . . . . . . . .7-177-177-177-187-22Preferences for the Editor/Debugger . . . . . . . . . . . . . . . . . . .General Preferences for the Editor/Debugger . . . . . . . . . . . . .Font & Colors Preferences for the Editor/Debugger . . . . . . . .Display Preferences for the Editor/Debugger . . . . . . . .
. . . . . .Keyboard and Indenting Preferences for the Editor/DebuggerPrinting Preferences for the Editor/Debugger . . . . . . . . . . . . .7-357-367-377-387-407-42Improving M-File Performance – the Profiler8What Is Profiling? . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . 8-3Using the Profiler . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4The profile Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-4An Example Using the Profiler . . . . . . . . . . . . . . . . . . . . .
. . . . . 8-6Viewing Profiler Results . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7Viewing Profile Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-7Profile Plot . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-12Saving Profile Reports . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8-13viContentsInterfacing with Source Control Systems9Process of Interfacing to an SCS . . . . . . . . . . . . . . . . . . . . . . . . 9-3Viewing or Selecting the Source Control System . . . . . . . . . 9-4Function Alternative for Viewing the SCS . . .
. . . . . . . . . . . . . . 9-5Setting Up the Source Control System . . . . . . . . . . . . . . . . . . 9-6For SourceSafe Only – Mirroring MATLAB Hierarchy . . . . . . . 9-6For ClearCase on UNIX Only – Set a View andCheck Out a Directory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-6Checking Files into the Source Control System .
. . . . . . . . . 9-7Function Alternative for Checking In Files . . . . . . . . . . . . . . . . 9-8Checking Files Out of the SCS . . . . . . . . . . . . . . . . . . . . . . . . . . 9-9Function Alternative for Checking Out Files . . . . .
. . . . . . . . . 9-10Undoing the Check-Out . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9-10Using Notebook10Notebook Basics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Creating an M-Book . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . .Entering MATLAB Commands in an M-Book . . . . . . . . . . . .Protecting the Integrity of Your Workspace . . . . . . . . . . . . . . .Ensuring Data Consistency . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-310-310-610-610-7Defining MATLAB Commands as Input Cells . . .
. . . . . . . . 10-8Defining Cell Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-8Defining Autoinit Input Cells . . . . . . . . . . . . . . . . . . . . . . . . . 10-10Defining Calc Zones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-10Converting an Input Cell to Text . .
. . . . . . . . . . . . . . . . . . . . 10-11Evaluating MATLAB Commands . . . . . . . . . . . . . . . . . . . . . 10-12Evaluating Cell Groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-13viiEvaluating a Range of Input Cells . . . . . . . . . . . . . . . . . .
. . .Evaluating a Calc Zone . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Evaluating an Entire M-Book . . . . . . . . . . . . . . . . . . . . . . . . .Using a Loop to Evaluate Input Cells Repeatedly . . . . . . . . .Converting Output Cells to Text . . . . .
. . . . . . . . . . . . . . . . . .Deleting Output Cells . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .10-1410-1410-1510-1510-1610-17Printing and Formatting an M-Book . . . . . . . . . . . . . . . . . .Printing an M-Book . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . .Modifying Styles in the M-Book Template . . . . . . . . . . . . . . .Choosing Loose or Compact Format . . . . . . . . . . . . . . . . . . . .Controlling Numeric Output Format . . . . . . . . . . . . . . . . .
. .Controlling Graphic Output . . . . . . . . . . . . . . . . . . . . . . . . . .10-1810-1810-1810-1910-2010-20Configuring Notebook. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 10-24Notebook Command Reference . . . . . . . . . . . . . . . . . . . . . . .Bring MATLAB to Front Command . . . . . . . . . . . . . . .
. . . . .Define Autoinit Cell Command . . . . . . . . . . . . . . . . . . . . . . . .Define Calc Zone Command . . . . . . . . . . . . . . . . . . . . . . . . . .Define Input Cell Command . . . . . . . . . . . . . . . . . . . . . . . . . .Evaluate Calc Zone Command . . . . . . . . . . . . . . . . . . . . . .
. .Evaluate Cell Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Evaluate Loop Command . . . . . . . . . . . . . . . . . . . . . . . . . . . .Evaluate M-Book Command . . . . . . . . . . . . . . . . . . . . . . . . . .Group Cells Command . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . .Hide Cell Markers Command . . . . . . . . . . . . . . . . . . . . . . . . .Notebook Options Command . . . . . . . . . . . . . . . . . . . . . . . . . .Purge Output Cells Command . . . . . . . . . . . . . . . . . . . . . . . .Toggle Graph Output for Cell Command . . . . . . . .
. . . . . . . .Undefine Cells Command . . . . . . . . . . . . . . . . . . . . . . . . . . . .Ungroup Cells Command . . . . . . . . . . . . . . . . . . . . . . . . . . . . .viii Contents10-2610-2610-2610-2710-2710-2810-2810-2910-3010-3010-3110-3110-3110-3110-3210-32MathematicsMatrices and Linear Algebra11Function Summary . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-3Matrices in MATLAB . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 11-5Addition and Subtraction . . . .















