Programming |
Asterisk -- *
An asterisk in a filename specification is used as a wildcard specifier, as described below.
Filename Wildcard
Wildcards are generally used in file operations that act on multiple files or directories. They usually appear in the string containing the file or directory specification. MATLAB matches all characters in the name exactly except for the wildcard character *
, which can match any one or more characters.
To locate all files with names that start with 'january_'
and have a mat
file extension, use
You can also use wildcards with the who
and whos
functions. To get information on all variables with names starting with 'image'
and ending with 'Offset'
, use
At -- @
The @
sign signifies either a function handle constructor or a directory that supports a MATLAB class.
Function Handle Constructor
The @
operator forms a handle to either the named function that follows the @
sign, or to the anonymous function that follows the @
sign.
Function Handles in General. Function handles are commonly used in passing functions as arguments to other functions. Construct a function handle by preceding the function name with an @
sign:
You can read more about function handles in Function Handles.
Handles to Anonymous Functions. Anonymous functions give you a quick means of creating simple functions without having to create M-files each time. You can construct an anonymous function and a handle to that function using the syntax
where body
defines the body of the function and arglist
is the list of arguments you can pass to the function.
See Anonymous Functions for more information.
Class Directory Designator
A MATLAB class directory contains source files that define the methods and properties of a class. All MATLAB class directory names must begin with an @
sign:
See MATLAB Classes for more information.
Colon -- :
The colon operator generates a sequence of numbers that you can use in creating or indexing into arrays. See Generating a Numeric Sequence for more information on using the colon operator.
Numeric Sequence Range
Generate a sequential series of regularly spaced numbers from first
to last
using the syntax first:last
. For an incremental sequence from 6 to 17, use
Numeric Sequence Step
Generate a sequential series of numbers, each number separated by a step
value, using the syntax first:step:last
. For a sequence from 2 through 38, stepping by 4 between each entry, use
Indexing Range Specifier
Index into multiple rows or columns of a matrix using the colon operator to specify a range of indices:
B = A(7, 1:5); % Read columns 1-5 of row 7. B = A(4:2:8, 1:5); % Read columns 1-5 of rows 4, 6, and 8. B = A(:, 1:5); % Read columns 1-5 of all rows.
Conversion to Column Vector
Convert a matrix or array to a column vector using the colon operator as a single index:
Preserving Array Shape on Assignment
Using the colon operator on the left side of an assignment statement, you can assign new values to array elements without changing the shape of the array:
Symbol Reference | Comma -- , |
© 1994-2005 The MathWorks, Inc.