Graphics Programs Reference
In-Depth Information
eye
The function
eye
X
= eye(
n
)
×
creates an
n
n
identitymatrix.
Array Functions
There are numerous array functions in MATLAB that performmatrix operations and
otherusefultasks. Here are a fewbasicfunctions:
length
The length
n
(number of elements) of avector
x
can be determinedwith the function
length
:
n
= length(
x
)
size
If the function
size
iscalledwith a single input argument:
[
m
,
n
] = size(
X
)
it determines the number of rows
m
and number of columns
n
in the matrix
X
. If
calledwith two input arguments:
m
= size(
X
,
dim
)
it returns the length of
X
in the specified dimension (
dim
=1
yields the number of
rows, and
dim
=
2 gives the number of columns).
reshape
The reshapefunctionis used to rearrange the elements of amatrix. The call
Y
= reshape(
X
,
m
,
n
)
returns a
m
n
matrix the elements of which aretaken frommatrix
X
in the column-
wise order. The total number of elements in
X
must beequalto
m
×
×
n
. Here is an
example:
Search WWH ::
Custom Search