Tài liệu MATLAB ® The Language of Technical Computing P2 ppt

20 531 0
Tài liệu MATLAB ® The Language of Technical Computing P2 ppt

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Starting MATLAB 1-5 Startup Options You can define startup options for MATLAB, which instruct MATLAB to perform certain operations upon startup. There are two ways to specify startup options 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 “Adding Startup Options for UNIX Platforms” on page 1-7 Using the Startup File for MATLAB, startup.m At startup, MATLAB automatically executes the master M-file matlabrc.m and, if it exists, startup.m . The file matlabrc.m , which lives in the local directory, is reserved for use by The MathWorks, and on multiuser systems, by your system manager. The file startup.m is for you to use to specify startup options. You can modify the default search path, predefine variables in your workspace, or define Handle Graphics  defaults. For example, creating a startup.m file with the line addpath \home\me\mytools cd \home\me\mytools adds \home\me\mytools to your default search path and makes that directory the current directory upon startup. On Windows platforms, place the startup.m file in $matlabroot\toolbox\local , where $matlabroot is the directory in which MATLAB is installed. On UNIX workstations, place the startup.m file in the directory named matlab off of your home directory, for example, ~/matlab . Adding Startup Options for Windows Platforms You can add selected startup options (also called command flags) to the target path for your Windows shortcut for MATLAB, or include the option if you start MATLAB from a DOS window. To do so: 1 Starting and Quitting MATLAB 1-6 1 Right-click on the MATLAB shortcut icon and select Properties from the context 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 of the allowable startup options listed here. Option Description /automation Start MATLAB as an automation server, minimized and without the MATLAB splash screen. For more information, see “Client/Server Applications” in the External Interfaces Guide. /c licensefile Set LM_LICENSE_FILE to licensefile . It can have the form port@host . /logfile logfilename Automatically write output from MATLAB to the specified log file. /minimize Start MATLAB minimized and without the MATLAB splash screen. /nosplash Start MATLAB without displaying the MATLAB splash screen. /r M_file Automatically run the specified M-file immediately after MATLAB starts. This is also referred to as calling MATLAB in batch mode. /regserver Modify the Windows registry with the appropriate ActiveX entries for MATLAB. For more information, see “Client/Server Applications” in the External Interfaces Guide. /unregserver Modify the Windows registry to remove the ActiveX entries for MATLAB. Use this option to reset the registry. For more information, see “Client/Server Applications” in the External Interfaces Guide. Starting MATLAB 1-7 3 Click OK . Example – Setting the Startup Options to Automatically Run an M-File. To start MATLAB and automatically run the file results.m , use this target path for your Windows shortcut. D:\matlabr12\bin\win32\matlab.exe /r results Startup Options If You Run MATLAB from a DOS Window. If you run MATLAB from a DOS window, include the startup options listed in the preceding table after the matlab startup function. For example, to start MATLAB and automatically run the file results.m , type matlab /r results Adding Startup Options for UNIX Platforms Include startup options (also called command flags) after the matlab startup function. The startup options for UNIX are listed in the following table Option Description -arch Run MATLAB assuming architecture arch . -arch/ext Run the version of MATLAB with the extension ext if it exists, assuming architecture arch . -c licensefile Set LM_LICENSE_FILE to licensefile . It can have the form port@host . -Ddebugger [options] Start MATLAB with the specified debugger. -debug Turn on MATLAB internal debugging. -display Xserver Send X commands to Xserver . -ext Run the version of MATLAB with the extension ext , if it exists. -h or -help Displays startup options. 1 Starting and Quitting MATLAB 1-8 -mwvisual visualid Specify the default X visual to use for figure windows. -n Print environment variables only. -nodesktop Start MATLAB without bringing up the MATLAB desktop. Use this option to run without an X-window, for example, in VT100 mode, or in batch processing mode. Note that if you pipe to MATLAB using the > constructor, the nodesktop option is used automatically. With nodesktop , you can still use most development environment tools by starting them with a function. Specifically use: • edit to open the Editor/Debugger • helpbrowser to open the Help browser • filebrowser to open the Current Directory browser • workspace to open the Workspace browser • openvar to open the Array Editor You cannot use the LaunchPad and the Command History window in -nodesktop mode. Don’t use nodesktop to provide a command line interface, if you prefer that over the desktop tools. Instead, select View -> Desktop Layout -> Command Window Only . Option Description (Continued) Starting MATLAB 1-9 For example, to start MATLAB without the splash screen, type matlab -nosplash -nojvm Start MATLAB without loading the Java VM. This minimizes memory usage and improves initial startup speed. With nojvm , you cannot use the desktop, nor any of the tools that require Java. The restrictions are the same as those described under UNIX Platform Limitations in the R12 Release Notes. -nosplash Start MATLAB without displaying the splash screen during startup. Option Description (Continued) 1 Starting and Quitting MATLAB 1-10 Reducing Startup Time with Toolbox Path Caching If you run MATLAB from a network server, you can significantly reduce your startup time by using the MATLAB toolbox path cache. The toolbox path cache stores search path information on all toolbox directories under the MATLAB root directory. During startup, MATLAB obtains this information from the cache rather than by reading it from the remote file system. The toolbox path cache is used only during the startup of your MATLAB session. It is especially useful if you define your MATLAB search path to include many toolbox directories. It takes considerable time to acquire all of this information by scanning directories in the remote file system. Reading it from a pre-generated cache however, is significantly faster. If you have a short toolbox path, there is less benefit to using the cache, but it does still provide a time savings. If you run MATLAB on a local disk, where your files are not served from a remote system, then the cache may provide no noticeable reduction in startup time. In this case, you may want to leave the toolbox path cache disabled. Selecting Toolbox Path Cache Preferences To generate and enable or disable the toolbox path cache, use MATLAB preferences. 1 From the MATLAB desktop, select Preferences from the File menu. The Preferences dialog box appears. Starting MATLAB 1-11 2 In the left pane of the dialog box, click General to display the General Preferences panel in the right pane. 3 To use the cache or to regenerate the cache, select Enable toolbox cache under Toolbox caching . With Enable toolbox cache selected, MATLAB displays summary information during startup, sends notification when it loads the toolbox directories from the cache, and displays a warning if the toolbox path cache cannot be found. 1 Starting and Quitting MATLAB 1-12 4 For additional information, select Enable toolbox cache diagnostics . With Enable toolbox cache diagnostics selected, MATLAB displays additional information at startup. MATLAB also provides warnings whenever a toolbox directory is added to the path from the remote file system at startup rather than from the cache. This occurs if the cache has not been kept up to date with changes in the toolbox directories. 5 To generate a new copy of the cache, select Update Toolbox Cache . See “Generating the Toolbox Path Cache” on page 1-12 for more information. To use this, you need write access to the directory that holds the cache file. The button will be grayed out if you don’t have write access. 6 Select OK . Generating the Toolbox Path Cache The toolbox path cache is in a MAT-file in the toolbox/local directory on the system that serves files for MATLAB. When you first install MATLAB on this system, you or your system administrator needs to generate the cache. (MATLAB does not ship with a prebuilt cache). You also need to regenerate the cache file whenever toolbox directories are added or removed so that the cache does not hold out-dated path information. To do so, select Update Toolbox Cache as described in “Selecting Toolbox Path Cache Preferences” on page 1-10. Function Equivalent. To update the cache, type the following in the Command Window. rehash toolboxcache Enabling Use of the Cache When MATLAB is first installed, the toolbox path cache feature is disabled. In order to make use of the cache on a distributed file system: 1 The system administrator enables caching and generates the initial toolbox path cache on the system that serves files for MATLAB. This is explained in “Generating the Toolbox Path Cache” on page 1-12. Starting MATLAB 1-13 2 Each user that intends to use toolbox directory caching enables the cache on their own system. On a nondistributed system, the system user performs both steps. To enable toolbox path caching, follow the instructions under “Selecting Toolbox Path Cache Preferences” on page 1-10. You can disable the use of this feature either on a user-by-user basis or on a global basis. To disable it on a per-user basis, uncheck Enable toolbox cache in the Preferences dialog box. To disable it on a global basis, remove the file toolbox_cache.mat from the toolbox/local directory. Updating the Cache If you make changes to your toolbox directories, your toolbox path cache file can become out of date. Depending upon the reason for this, you may or may not receive a warning that your cache needs to be updated. This section explains when you need to update your toolbox path cache and how to avoid problems caused by an out-dated cache file. Updating Cache Following a Product Install or Update. If you install a new toolbox or an update from The MathWorks, it is likely that the information stored in the toolbox path cache no longer accurately reflects your toolbox directories. As part of the installation process, the MATLAB installer marks the cache as being invalid. When your cache is marked invalid, MATLAB ceases to use cache during startup, loading path information by accessing the directories through the file system instead. MATLAB issues a message at startup to warn you that your toolbox path cache is out-dated and is being ignored. To resume use of the cache, you need to regenerate it using the procedure described in “Generating the Toolbox Path Cache” on page 1-12. Updating Cache Following Changes to Toolbox Directories. If you make changes to the MATLAB toolbox directories (for example, by adding or deleting files), the path information in the toolbox path cache file becomes out of date. When you start up your next MATLAB session, this out-dated path information will be loaded into memory from the cache. MATLAB does not issue a warning when this occurs. 1 Starting and Quitting MATLAB 1-14 If you choose to make changes that affect the toolbox path, you must regenerate the cache file using the procedure described in “Generating the Toolbox Path Cache” on page 1-12. Caution The MathWorks strongly recommends that you do not do development work in the toolbox area when toolbox path caching is enabled. If do you use the toolbox area for this purpose and neglect to regenerate the cache afterwards, MATLAB will use an inaccurate record of your toolbox directories in subsequent MATLAB sessions. As a result, MATLAB will be unable to locate new files that you have added. [...]... information on the MathWorks Web site Click + to show the listing for a product To display the listings for a product, click the + to the left of the product To collapse the listings, click the - to the left of the product To open one of the listings, double-click it, or right-click and select Open from the context menu The action depends on the listing you selected, as described in the following table... with MATLAB Think of the desktop as your instrument panel for MATLAB The main things you need to know about the desktop are: • “Desktop Tools” on page 2-4 – All of the tools managed by the desktop • “Configuring the Desktop” on page 2-7 – Arranging the tools in the desktop • “Common Desktop Features” on page 2-17 – Features you can use in the tools, such as context menus The first time MATLAB starts, the. ..Quitting MATLAB Quitting MATLAB To quit MATLAB at any time, do one of the following: • Select the close box in the MATLAB desktop • Select Exit MATLAB from the desktop File menu • Type quit at the Command Window prompt MATLAB closes immediately, without issuing a warning If you want to see a warning, use the finishdlg.m script as described in the next paragraph Running a Script When Quitting MATLAB When MATLAB. .. Tools To open a tool from the desktop, select the tool from the View menu or double-click it in the list of tools displayed in the Launch Pad for MATLAB The tool opens in the location it occupied the last time it was open There are a few tools controlled by the desktop that you don’t open from the View menu or Launch Pad: • Array Editor – Open it by double-clicking a variable in the Workspace Browser •... Using the Desktop Desktop Tools The following tools are managed by the MATLAB desktop, although not all of them appear by default when you first start If you prefer a command line interface, you can use functions to perform most of the features found in the MATLAB desktop tools Instructions for using these function equivalents are provided with the documentation for each tool • Command Window – Run MATLAB. .. when the MATLAB session was started If you change the search path after the start of a session, such as by adding a toolbox directory, the Launch Pad is not automatically updated Right-click in the Launch Pad and select Refresh from the context menu to update the Launch Pad so it reflects all products on the current search path Adding Your Own Entries to the Launch Pad You can add your own entries to the. .. select one of the existing entries in the Launch Pad, right-click, and select Edit Source from the context menu The info.xml file for that product appears The line for the tool you selected appears highlighted Create a similar info.xml file for your own application and put it in a folder that is on the search path Right-click in the Launch Pad and select Refresh from the context menu to update the Launch... History – View a log of the functions you entered in the Command Window, copy them, and execute them • Launch Pad – Run tools and access documentation for all of your MathWorks products • Current Directory Browser – View MATLAB files and related files, and perform file operations such as open, and find content • Help Browser – View and search the documentation for the full family of MATLAB products •... Description of Action When Opened Documentation roadmap page for that product opens in the Help browser Demo launcher opens, with the demo for that product selected Selected tool opens Product Page, which contains the latest product information on the MathWorks Web site, opens in your Web browser 2-5 2 Using the Desktop Refreshing the Launch Pad The Launch Pad includes entries for all products found on the MATLAB. .. changes to the contents of the workspace • Array Editor – View array contents in a table format and edit the values • Editor/Debugger – Create, edit, and debug M-files (files containing MATLAB functions) Other MATLAB tools and windows, such as figure windows, are not managed by the desktop 2-4 Desktop Tools Launch Pad MATLAB s Launch Pad provides easy access to tools, demos, and documentation for all of your . product, click the + to the left of the product. To collapse the listings, click the - to the left of the product. To open one of the listings, double-click. from the desktop, select the tool from the View menu or double-click it in the list of tools displayed in the Launch Pad for MATLAB. The tool opens in the

Ngày đăng: 22/12/2013, 20:16

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan