- •Version of matlab on different machines. It does not offer direct
- •In the workspace or file. You must use the functional form of who when
- •In a nested function, variables are grouped into those in the nested
- •If you run out of memory often, here are some additional system
- •If you do not specify filename, the load function searches for a file
- •If any data items require features that the specified version does not
- •Valid options for format are:
- •VirtualAddressSpace: [1x1 struct]
- •If the flag -inplace is used, the result is placed in the same
- •Inmem List functions in memory.
- •Variable names
- •Visible.
- •Is automatically run.
- •Is stored in a string.
- •Controlling the command window.
- •Vdspdebug/cd
- •Input parameters:
- •If the specified name cannot be found, an empty matrix is returned.
- •Idivide - Integer division with rounding option.
- •Interactive user input which cannot be provided.
- •Debugging.
- •If the matlabpath contains 'relative' directories then any file in those
- •Indicates who calls whom. Called_from is arranged so that
- •Information from the shrlib library file. Notfound is a cell array of
- •Invoked from the Swing Event Dispatch Thread.
matlab\general – Команды общего назначения
General information
syntax - Help on MATLAB command syntax.
You can enter MATLAB commands using either a FUNCTION format or a
COMMAND format, as described below.
FUNCTION FORMAT
A command in this format consists of the function name followed by
one or more arguments separated by commas and enclosed in parentheses.
functionname(arg1, arg2, ..., argn)
You may assign the output of the function to one or more output values
separated by commas and enclosed in square brackets ([]).
[out1, out2, ..., outn] = functionname(arg1, arg2, ..., argn)
For example,
copyfile(srcfile, '..\mytests', 'writable')
[x1, x2, x3, x4] = deal(A{:})
Arguments are passed to the function by value. See the examples below,
under ARGUMENT PASSING.
COMMAND FORMAT
A command in this format consists of the function name followed by
one or more arguments separated by spaces.
functionname arg1 arg2 ... argn
Unlike the function format, you may not assign the output of the function
to a variable. Attempting to do so generates an error.
For example
save mydata.mat x y z
import java.awt.Button java.lang.String
Arguments are treated as string literals. See the examples below,
under ARGUMENT PASSING.
ARGUMENT PASSING
In the FUNCTION format, arguments are passed by value.
In the COMMAND format, arguments are treated as string literals.
In the following example,
disp(A) - passes the value of variable A to the disp function
disp A - passes the variable name, 'A'
A = pi;
disp(A) % Function format
3.1416
disp A % Command format
A
In the next example,
strcmp(str1, str2) - compares the strings 'one' and 'one'
strcmp str1 str2 - compares the strings 'str1' and 'str2'
str1 = 'one'; str2 = 'one';
strcmp(str1, str2) % Function format
ans =
1 (equal)
strcmp str1 str2 % Command format
ans =
0 (unequal)
PASSING STRINGS
When using the FUNCTION format to pass a string literal to a function,
you must enclose the string in single quotes, ('string').
For example, to create a new directory called MYAPPTESTS, use
mkdir('myapptests')
On the other hand, variables that contain strings do not need to be
enclosed in quotes.
dirname = 'myapptests';
mkdir(dirname)
See also mlint.
Reference page in Help browser
doc syntax
demo - Run demonstrations.
DEMO Access product demos via Help browser.
DEMO opens the Help browser and selects the MATLAB Demos
entry in the table of contents.
DEMO SUBTOPIC CATEGORY opens the Demos entry to the specified CATEGORY.
CATEGORY is a product or group within SUBTOPIC. SUBTOPIC is 'matlab',
'toolbox', 'simulink', 'blockset', or 'links and targets'. When
SUBTOPIC is 'matlab' or 'simulink', do not specify CATEGORY to show all
demos for the product.
Examples:
demo 'matlab'
demo 'toolbox' 'signal'
demo 'matlab' 'getting started'
See also echodemo, grabcode, help, helpbrowser.
Reference page in Help browser
doc demo
ver - MATLAB, Simulink and toolbox version information.
VER MATLAB, Simulink and toolbox version information.
VER displays MathWorks product family header information, followed by
the current MATLAB, Simulink and toolbox version information.
VER(TOOLBOX_DIR) displays the current version information for the
toolbox specified by the string TOOLBOX_DIR.
A = VER displays the general MATLAB version header and return in A the
sorted struct array of version information on all toolboxes on the
MATLAB path.
The definition of struct A is:
A.Name : toolbox name
A.Version : toolbox version number
A.Release : toolbox release string
A.Date : toolbox release date
For example,
ver control
displays the version info for the Control System Toolbox, sorted
alphabetically.
A = ver('control');
returns in A the version information for the Control System Toolbox,
sorted alphabetically.
For tips on how to get VER to display version information about
your toolbox, type at the MATLAB prompt
more on
type ver.m
and then type 'more off' when the display of ver.m has finished.
See also hostid, info, license, verLessThan, version, whatsnew.
Reference page in Help browser
doc ver
<version> - MATLAB version information.
VERSION Version information for MATLAB and libraries.
VERSION returns a string containing MathWorks product family version
information.
VERSION returns the full MathWorks product family
version string
VERSION('-date') returns the release date
VERSION('-release') returns the release number
VERSION('-description') returns the release description
VERSION('-java') returns Java version information
See also computer, ver, verLessThan, whatsnew.
Reference page in Help browser
doc version
< verLessThan> - Compare version of toolbox to specified version string.
verLessThan Compare version of toolbox to specified version string.
verLessThan(TOOLBOX_DIR, VERSION) returns true if the version of
the toolbox specified by the string TOOLBOX_DIR is older than the
version specified by the string VERSION, and false otherwise.
VERSION must be a string in the form 'major[.minor[.revision]]',
such as '7', '7.1', or '7.0.1'. If TOOLBOX_DIR cannot be found
on MATLAB's search path, an error is generated.
Examples:
if verLessThan('images', '4.1')
error('Image Processing Toolbox 4.1 or higher is required.');
end
if verLessThan('matlab', '7.0.1')
% Put code to run under MATLAB older than MATLAB 7.0.1 here
else
% Put code to run under MATLAB 7.0.1 and newer here
end
See also matlabpath, ver.
Reference page in Help browser
doc verLessThan
< logo > - Plot the L-shaped membrane logo with MATLAB lighting.
Logo
Plot the L-shaped membrane logo with MATLAB(R) lighting.
< membrane > - Generates the MATLAB logo.
MEMBRANE Generates the MATLAB logo.
L = MEMBRANE(k), for k <= 12, is the k-th eigenfunction of
the L-shaped membrane. The first three eigenfunctions have
been shown on the covers of various MathWorks publications.
MEMBRANE(k), with no output parameters, plots the k-th eigenfunction.
MEMBRANE, with no input or output parameters, plots MEMBRANE(1).
L = MEMBRANE(k,m,n,np) also sets some mesh and accuracy parameters:
k = index of eigenfunction, default k = 1.
m = number of points on 1/3 of boundary. The size of
the output is 2*m+1-by-2*m+1. The default m = 15.
n = number of terms in sum, default n = min(m,9).
np = number of terms in partial sum, default np = min(n,2).
With np = n, the eigenfunction is nearly zero on the boundary.
With np < n, like np = 2, the boundary is not tied down.
< bench > - MATLAB Benchmark.
BENCH MATLAB Benchmark
BENCH times six different MATLAB tasks and compares the execution
speed with the speed of several other computers. The six tasks are:
LU LAPACK. Floating point, regular memory access.
FFT Fast Fourier Transform. Floating point, irregular memory access.
ODE Ordinary diff. eqn. Data structures and functions.
Sparse Solve sparse system. Sparse linear algebra.
2-D plot(fft(eye)). 2-D line drawing graphics.
3-D MathWorks logo. 3-D animated OpenGL graphics.
A final bar chart shows speed, which is inversely proportional to
time. Here, longer bars are faster machines, shorter bars are slower.
BENCH runs each of the six tasks once.
BENCH(N) runs each of the six tasks N times.
BENCH(0) just displays the results from other machines.
T = BENCH(N) returns an N-by-6 array with the execution times.
The comparison data for other computers is stored in a text file:
fullfile(matlabroot, 'toolbox','matlab','general','bench.dat')
Updated versions of this file are available from MATLAB Central
Note the link above opens your system web browser as defined by WEB.
Fluctuations of five or 10 percent in the measured times of repeated
runs on a single machine are not uncommon. Your own mileage may vary.
This benchmark is intended to compare performance of one particular
Version of matlab on different machines. It does not offer direct
comparisons between different versions of MATLAB. The tasks and
problem sizes change from version to version.
The 2-D and 3-D tasks measure graphics performance, including software
or hardware support for OpenGL. The command
opengl info
describes the OpenGL support available on a particular machine.
Reference page in Help browser
doc bench
Managing the workspace
<who> - List current variables.
WHO List current variables.
WHO lists the variables in the current workspace.
In a nested function, variables are grouped into those in the nested
function and those in each of the containing functions. WHO displays
only the variables names, not the function to which each variable
belongs. For this information, use WHOS. In nested functions and
in functions containing nested functions, even unassigned variables
are listed.
WHOS lists more information about each variable.
WHO GLOBAL and WHOS GLOBAL list the variables in the global workspace.
WHO -FILE FILENAME lists the variables in the specified .MAT file.
WHO ... VAR1 VAR2 restricts the display to the variables specified. The
wildcard character '*' can be used to display variables that match a
pattern. For instance, WHO A* finds all variables in the current
workspace that start with A.
WHO -REGEXP PAT1 PAT2 can be used to display all variables matching the
specified patterns using regular expressions. For more information on
using regular expressions, type "doc regexp" at the command prompt.
Use the functional form of WHO, such as WHO('-file',FILE,V1,V2),
when the filename or variable names are stored in strings.
S = WHO(...) returns a cell array containing the names of the variables
In the workspace or file. You must use the functional form of who when
there is an output argument.
Examples for pattern matching:
who a* % Show variable names starting with "a"
who -regexp ^b\d{3}$ % Show variable names starting with "b"
% and followed by 3 digits
who -file fname -regexp \d % Show variable names containing any
% digits that exist in MAT-file fname
See also whos, clear, clearvars, save, load.
Overloaded methods:
Simulink.who
Reference page in Help browser
doc who
<whos> - List current variables, long form.
WHOS List current variables, long form.
WHOS is a long form of WHO. It lists all the variables in the current
workspace, together with information about their size, bytes, class,
etc.
In a nested function, variables are grouped into those in the nested
function and those in each of the containing functions, each group
separated by a line of dashes. In nested functions and in functions
containing nested functions, even uninitialized variables are listed.
WHOS GLOBAL lists the variables in the global workspace.
WHOS -FILE FILENAME lists the variables in the specified .MAT file.
WHOS ... VAR1 VAR2 restricts the display to the variables specified.
The wildcard character '*' can be used to display variables that match
a pattern. For instance, WHOS A* finds all variables in the current
workspace that start with A.
WHOS -REGEXP PAT1 PAT2 can be used to display all variables matching
the specified patterns using regular expressions. For more information
on using regular expressions, type "doc regexp" at the command prompt.
Use the functional form of WHOS, such as WHOS('-file',FILE,V1,V2), when
the filename or variable names are stored in strings.
S = WHOS(...) returns a structure with the fields:
name -- variable name
size -- variable size
bytes -- number of bytes allocated for the array
class -- class of variable
global -- logical indicating whether variable is global
sparse -- logical indicating whether value is sparse
complex -- logical indicating whether value is complex
nesting -- struct with the following two fields:
function -- name of function where variable is defined
level -- nesting level of the function
persistent -- logical indicating whether variable is persistent
You must use the functional form of WHOS when there is an output
argument.
Examples for pattern matching:
whos a* % Show variable names starting with "a"
whos -regexp ^b\d{3}$ % Show variable names starting with "b"
% and followed by 3 digits
whos -file fname -regexp \d % Show variable names containing any
% digits that exist in MAT-file fname
See also who, clear, clearvars, save, load.
Overloaded methods:
Simulink.whos
Reference page in Help browser
doc whos
<clear> - Clear variables and functions from memory.
CLEAR Clear variables and functions from memory.
CLEAR removes all variables from the workspace.
CLEAR VARIABLES does the same thing.
CLEAR GLOBAL removes all global variables.
CLEAR FUNCTIONS removes all compiled M- and MEX-functions.
CLEAR ALL removes all variables, globals, functions and MEX links.
CLEAR ALL at the command prompt also removes the Java packages import
list.
CLEAR IMPORT removes the Java packages import list at the command
prompt. It cannot be used in a function.
CLEAR CLASSES is the same as CLEAR ALL except that class definitions
are also cleared. If any objects exist outside the workspace (say in
userdata or persistent in a locked m-file) a warning will be issued and
the class definition will not be cleared. CLEAR CLASSES must be used if
the number or names of fields in a class are changed.
CLEAR JAVA is the same as CLEAR ALL except that java classes on the
dynamic java path (defined using JAVACLASSPATH) are also cleared.
CLEAR VAR1 VAR2 ... clears the variables specified. The wildcard
character '*' can be used to clear variables that match a pattern. For
instance, CLEAR X* clears all the variables in the current workspace
that start with X.
CLEAR -REGEXP PAT1 PAT2 can be used to match all patterns using regular
expressions. This option only clears variables. For more information on
using regular expressions, type "doc regexp" at the command prompt.
If X is global, CLEAR X removes X from the current workspace, but
leaves it accessible to any functions declaring it global.
CLEAR GLOBAL X completely removes the global variable X.
CLEAR GLOBAL -REGEXP PAT removes global variables that match regular
expression patterns.
Note that to clear specific global variables, the GLOBAL option must
come first. Otherwise, all global variables will be cleared.
CLEAR FUN clears the function specified. If FUN has been locked by
MLOCK it will remain in memory. Use a partial path (see PARTIALPATH) to
distinguish between different overloaded versions of FUN. For
instance, 'clear inline/display' clears only the INLINE method for
DISPLAY, leaving any other implementations in memory.
CLEAR ALL, CLEAR FUN, or CLEAR FUNCTIONS also have the side effect of
removing debugging breakpoints and reinitializing persistent variables
since the breakpoints for a function and persistent variables are
cleared whenever the m-file changes or is cleared.
Use the functional form of CLEAR, such as CLEAR('name'), when the
variable name or function name is stored in a string.
Examples for pattern matching:
clear a* % Clear variables starting with "a"
clear -regexp ^b\d{3}$ % Clear variables starting with "b" and
% followed by 3 digits
clear -regexp \d % Clear variables containing any digits
See also clearvars, who, whos, mlock, munlock, persistent.
Overloaded methods:
mbcstore/clear
cgrules/clear
cgoptimexprgroup/clear
xregdesign/clear
cgexprgroup/clear
xregtable/clear
Reference page in Help browser
doc clear
<onCleanup> - Specify cleanup work to be done on function completion.
onCleanup - Specify cleanup work to be done on function completion.
C = onCleanup(S), when called in function F, specifies any cleanup tasks
that need to be performed when F completes. S is a handle to a function
that performs necessary cleanup work when F exits (e.g., closing files that
have been opened by F). S will be called whether F exits normally or
because of an error.
onCleanup is a MATLAB class and C = onCleanup(S) constructs an instance C of
that class. Whenever an object of this class is explicitly or implicitly
cleared from the workspace, it runs the cleanup function, S. Objects that
are local variables in a function are implicitly cleared at the termination
of that function.
Example 1: Use onCleanup to close a file.
function fileOpenSafely(fileName)
fid = fopen(fileName, 'w');
c = onCleanup(@()fclose(fid));
functionThatMayError(fid);
end % c will execute fclose(fid) here
Example 2: Use onCleanup to restore the current directory.
function changeDirectorySafely(fileName)
currentDir = pwd;
c = onCleanup(@()cd(currentDir));
functionThatMayError;
end % c will execute cd(currentDir) here
See also: clear, clearvars
Reference page in Help browser
doc onCleanup
< pack> - Consolidate workspace memory.
PACK Consolidate workspace memory.
PACK performs memory garbage collection. Extended MATLAB
sessions may cause memory to become fragmented, preventing
large variables from being stored. PACK is a command that
saves all variables on disk, clears the memory, and then
reloads the variables.