Using MATLAB (779505), страница 6
Текст из файла (страница 6)
. . . . . . . . . . . . . . . . . . . . . . . . . .The loadobj Method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .Changing the Portfolio Constructor . . . . . . . . . . . . . . . . . . . .The Portfolio subsref Method . . . . . . . . .
. . . . . . . . . . . . . . . .22-6122-6122-6222-6222-6322-64Object Precedence . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22-65Specifying Precedence of User-Defined Classes . . . . . . . . . . . 22-66How MATLAB Determines Which Method to Call . . . . . . 22-67Selecting a Method . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22-67Querying Which Method MATLAB Will Call . . . . . . . . . . . . . 22-70External Interfaces and the MATLAB APIAFinding the Documentation in Online Help . . . . . . . . . . . . . . A-2Reference Documentation . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . A-4xxixxii ContentsDevelopment EnvironmentThe MATLAB development environment is a set of tools to help you useMATLAB functions and files. Many of these tools are graphical user interfaces.Fundamentals• “Starting and Quitting MATLAB” – How to run MATLAB, and startup andshutdown options.• “Using the Desktop” – The MATLAB desktop is what you first see when youstart MATLAB. It manages the other tools, including the Launch Pad, whichis described here.• “Running MATLAB Functions” – Working in the Command Window andCommand History window.• “Getting Help” – The Help browser, help functions, printed documentation,and other ways to get help.Additional Development Environment Tools• “Workspace, Search Path, and File Operations” – Use the Workspacebrowser, Array Editor, search path tool, Current Directory browser, andequivalent functions.• “Importing and Exporting Data” – Techniques for bringing data created byother applications into the MATLAB workspace, including the ImportWizard, and packaging MATLAB workspace variables for use by otherapplications.• “Editing and Debugging M-Files” – MATLAB’s graphical Editor/Debuggerand debugging functions for creating and changing M-files (program filescontaining MATLAB functions).• “Improving M-File Performance – the Profiler” – Tool that measures wherean M-file is spending its time.
Use it help you make speed improvements.• “Interfacing with Source Control Systems” – Access your source controlsystem from within MATLAB, Simulink, and Stateflow.• “Using Notebook” – Access MATLAB’s numeric computation andvisualization software from within a word processing environment(Microsoft Word).1Starting and QuittingMATLABStarting MATLAB . . . .
. . . . . . . . .Starting MATLAB on Windows Platforms . . . .Starting MATLAB on UNIX Platforms . . . . . .Startup Directory for MATLAB . . . . . . . . .Startup Options . . . . . . . . . . . . . . .Reducing Startup Time with Toolbox Path Caching .........................1-31-31-31-31-51-10Quitting MATLAB . . . . .
. . . . . . . . . . . . 1-15Running a Script When Quitting MATLAB . . . . . . . . 1-151Starting and Quitting MATLABThese sections describe how to start and quit MATLAB, including optionsassociated with starting and quitting.• “Starting MATLAB on Windows Platforms” on page 1-3• “Starting MATLAB on UNIX Platforms” on page 1-3• “Startup Directory for MATLAB” on page 1-3• “Startup Options” on page 1-5• “Reducing Startup Time with Toolbox Path Caching” on page 1-10• “Quitting MATLAB” on page 1-15• “Running a Script When Quitting MATLAB” on page 1-151-2Starting MATLABStarting MATLABInstructions for starting MATLAB depend on your platform.
For a list ofsupported platforms, see the system requirements in the Installation Guide foryour platform or the Products section of the MathWorks Web site,http://www.mathworks.com.Starting MATLAB on Windows PlatformsTo start MATLAB on a Microsoft Windows platform, double-click the MATLABshortcut iconon your Windows desktop. The shortcut was automaticallycreated by the installer in the installation directory.If you start MATLAB from a DOS window, type matlab at the DOS prompt.After starting MATLAB, the MATLAB desktop opens – see Chapter 2, “Usingthe Desktop.”If you use a virus scanner, your settings may slow down MATLAB startup.
Forexample, if you use McAfee VirusScan, set the options to scan program filesonly.Starting MATLAB on UNIX PlatformsTo start MATLAB on a UNIX platform, type matlab at the operating systemprompt.After starting MATLAB, the MATLAB desktop opens – see Chapter 2, “Usingthe Desktop.” On UNIX platforms, if the DISPLAY environment variable is notset or is invalid, the desktop will not display. On some UNIX platforms, thedesktop is not supported – see the R12 Release Notes for details.Startup Directory for MATLABThe initial current directory in MATLAB depends on your platform andinstallation.
You can start MATLAB in a different directory.Startup Directory on Windows PlatformsOn Windows platforms, when you installed MATLAB, the default startupdirectory was set to $matlabroot\work, where $matlabroot is the directorywhere MATLAB files are installed.1-31Starting and Quitting MATLABStartup Directory on UNIX PlatformsOn UNIX platforms, the initial current directory is the directory you are in onyour UNIX file system when you invoke MATLAB.Changing the Startup DirectoryYou can start MATLAB in a different directory from the default. The directoryyou specify will be the current working directory when MATLAB starts. To doso:1 Create a startup.m file – see “Using the Startup File for MATLAB,startup.m” on page 1-5.2 In the startup.m file, include the cd function to change to the new directory.3 Put the startup.m file in the current startup directory.For Windows Platforms Only.
For Windows platforms, you can follow these steps tochange the startup directory:1 Right-click on the MATLAB shortcut icon and select Properties from thecontext menu.The Properties dialog box for matlab.exe opens to the Shortcut page.2 Enter the new startup directory in the Start in field and click OK.The next time you start MATLAB using that shortcut icon, the currentdirectory will be the one you specified in step 2.You can make multiple shortcuts to start MATLAB, each with its own startupdirectory, and each startup directory having different startup options.1-4Starting MATLABStartup OptionsYou can define startup options for MATLAB, which instruct MATLAB toperform certain operations upon startup.
There are two ways to specify startupoptions for MATLAB:• “Using the Startup File for MATLAB, startup.m” on page 1-5• “Adding Startup Options for Windows Platforms” on page 1-5 or “AddingStartup Options for UNIX Platforms” on page 1-7Using the Startup File for MATLAB, startup.mAt startup, MATLAB automatically executes the master M-file matlabrc.mand, if it exists, startup.m. The file matlabrc.m, which lives in the localdirectory, is reserved for use by The MathWorks, and on multiuser systems, byyour system manager.The file startup.m is for you to use to specify startup options. You can modifythe default search path, predefine variables in your workspace, or defineHandle Graphics defaults. For example, creating a startup.m file with thelineaddpath \home\me\mytoolscd \home\me\mytoolsadds \home\me\mytools to your default search path and makes that directorythe current directory upon startup.On Windows platforms, place the startup.m file in$matlabroot\toolbox\local, where $matlabroot is the directory in whichMATLAB is installed.On UNIX workstations, place the startup.m file in the directory named matlaboff of your home directory, for example, ~/matlab.Adding Startup Options for Windows PlatformsYou can add selected startup options (also called command flags) to the targetpath for your Windows shortcut for MATLAB, or include the option if you startMATLAB from a DOS window.
To do so:1-51Starting and Quitting MATLAB1 Right-click on the MATLAB shortcut iconand select Properties from thecontext menu.The Properties dialog box for matlab.exe opens to the Shortcut panel.2 In the Target field, after the target path for matlab.exe, add one or more ofthe allowable startup options listed here.1-6OptionDescription/automationStart MATLAB as an automation server,minimized and without the MATLAB splashscreen. For more information, see “Client/ServerApplications” in the External Interfaces Guide./c licensefileSet LM_LICENSE_FILE to licensefile.
It canhave the form port@host./logfile logfilenameAutomatically write output from MATLAB to thespecified log file./minimizeStart MATLAB minimized and without theMATLAB splash screen./nosplashStart MATLAB without displaying the MATLABsplash screen./r M_fileAutomatically run the specified M-fileimmediately after MATLAB starts. This is alsoreferred to as calling MATLAB in batch mode./regserverModify the Windows registry with theappropriate ActiveX entries for MATLAB. Formore information, see “Client/ServerApplications” in the External Interfaces Guide./unregserverModify the Windows registry to remove theActiveX entries for MATLAB.
Use this option toreset the registry. For more information, see“Client/Server Applications” in the ExternalInterfaces Guide.Starting MATLAB3 Click OK.Example – Setting the Startup Options to Automatically Run an M-File. To startMATLAB and automatically run the file results.m, use this target path foryour Windows shortcut.D:\matlabr12\bin\win32\matlab.exe /r resultsStartup Options If You Run MATLAB from a DOS Window. If you run MATLAB from aDOS window, include the startup options listed in the preceding table after thematlab startup function.For example, to start MATLAB and automatically run the file results.m , typematlab /r resultsAdding Startup Options for UNIX PlatformsInclude startup options (also called command flags) after the matlab startupfunction. The startup options for UNIX are listed in the following tableOptionDescription-archRun MATLAB assuming architecture arch.-arch/extRun the version of MATLAB with theextension ext if it exists, assumingarchitecture arch.-c licensefileSet LM_LICENSE_FILE to licensefile.
It canhave the form port@host.-Ddebugger [options]Start MATLAB with the specified debugger.-debugTurn on MATLAB internal debugging.-display XserverSend X commands to Xserver.-extRun the version of MATLAB with theextension ext, if it exists.-h or -helpDisplays startup options.1-71Starting and Quitting MATLABOptionDescription (Continued)-mwvisual visualidSpecify the default X visual to use for figurewindows.-nPrint environment variables only.-nodesktopStart MATLAB without bringing up theMATLAB desktop. Use this option to runwithout an X-window, for example, in VT100mode, or in batch processing mode. Note that ifyou pipe to MATLAB using the > constructor,the nodesktop option is used automatically.With nodesktop, you can still use mostdevelopment environment tools by startingthem with a function.















