
Col =
13
4
5
1
ans =
39 -310
297 314
Comments:
Matrix-vector and matrix-matrix products.
2.1.5 Special Cases of Matrices
Matlab has some very useful build-in matrices functions that ease the
manipulation of two dimensional arrays. These functions usually take as
input (at least) the matrix dimension and return a certain result. Table 3
exhibits these very useful functions accompanied with a short explanation of
their use.
e
e
y
y
e
e(m,n)
In the case where m is equal to n this returns an identity
matrix
o
o
n
n
e
e
s
s(m,n)
Creates an m-by-n matrix of ones
d
d
i
i
a
a
g
g(V)
When V is a m-by-m matrix returns the elements of the main
diagonal.
r
r
a
a
n
n
d
d(m,n)
Creates an m-by-n matrix with random entries
z
z
e
e
r
r
o
o
s
s(m,n)
Creates an m-by-n matrix of zeros
Table 3: Various functions that can be used with vectors.
Examples with the above matrix-functions follow:
Matlab’s command:
>> eye(3,2), ones(2,3), diag([2 3; 1 -2]), rand(2,2), zeros(1,2)
Matlab’s response:
ans =
1 0
0 1
0 0
ans =
1 1 1
1 1 1
ans =
2
-2
Komentáře k této Příručce