1. Trang chủ
  2. » Kỹ Thuật - Công Nghệ

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

20 532 0
Tài liệu đã được kiểm tra trùng lặp

Đ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

Thông tin cơ bản

Tiêu đề Starting MATLAB Startup Options
Định dạng
Số trang 20
Dung lượng 108,62 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

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

Trang 1

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:

Trang 2

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.

Trang 3

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

extension , if it exists

Trang 4

-mwvisual visualid Specify the default X visual to use for figure

windows

-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)

Trang 5

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)

Trang 6

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.

Trang 7

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

Trang 8

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

Trang 9

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

Trang 10

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

Trang 11

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 quits, it runs the script finish.m, if finish.m exists in the current directory or anywhere on the MATLAB search path You create the file

finish.m It contains functions to run when MATLAB terminates, such as saving the workspace or displaying a confirmation dialog box There are two sample files in $matlabroot\toolbox\local that you can use as the basis for your own finish.m file:

finishsav.m – Includes a save function so the workspace is saved to a MAT-file when MATLAB quits

finishdlg.m – Displays a confirmation dialog box that allows you to cancel quitting

Trang 13

Using the Desktop

Desktop Tools 2-4

Launch Pad 2-5

Configuring the Desktop 2-7

Opening and Closing Desktop Tools 2-7

Resizing Windows 2-9

Moving Windows 2-10

Using Predefined Desktop Configurations 2-16

Common Desktop Features 2-17

Desktop Toolbar 2-17

Context Menus 2-17

Keyboard Shortcuts and Accelerators 2-18

Selecting Multiple Items 2-19

Using the Clipboard 2-20

Accessing The MathWorks on the Web 2-20

Setting Preferences 2-21

General Preferences for MATLAB 2-23

Trang 14

When you start MATLAB, the MATLAB desktop appears, containing tools (graphical user interfaces) for managing files, variables, and applications associated 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 desktop appears as shown in the following illustration, although your Launch Pad may contain different entries

Trang 15

View or use previously run functions Use tabs to go to Workspace browser Drag the separator bar to resize windows

or Current Directory browser

Trang 16

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 functions.

• Command 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

• Workspace Browser – View and make 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

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

TỪ KHÓA LIÊN QUAN