Tải bản đầy đủ (.pdf) (20 trang)

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

Bạn đang xem bản rút gọn của tài liệu. Xem và tải ngay bản đầy đủ của tài liệu tại đây (108.62 KB, 20 trang )

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.

×