IP adress komputer Anda

Friday, June 26, 2009

MATRIX OPERATIONS

The basic matrix operations are addition(+), subtraction(-), multiplication (*),

and conjugate transpose(‘) of matrices. In addition to the above basic operations,

MATLAB has two forms of matrix division: the left inverse operator \

or the right inverse operator /.

Matrices of the same dimension may be subtracted or added. Thus if E and F

are entered in MATLAB as

E = [7 2 3; 4 3 6; 8 1 5];

F = [1 4 2; 6 7 5; 1 9 1];

and

G = E - F

H = E + F

then, matrices G and H will appear on the screen as

G =

6 -2 1

-2 -4 1

7 -8 4

H =

8 6 5

10 10 11

9 10 6

A scalar (1-by-1 matrix) may be added to or subtracted from a matrix. In this

particular case, the scalar is added to or subtracted from all the elements of another

matrix. For example,

J = H + 1

gives

J =

9 7 6

11 11 12

10 11 7

Matrix multiplication is defined provided the inner dimensions of the two operands

are the same. Thus, if X is an n-by-m matrix and Y is i-by-j matrix,

X*Y is defined provided m is equal to i. Since E and F are 3-by-3 matrices,

the product

Q = E*F

results as

Q =

22 69 27

28 91 29

19 84 26

Any matrix can be multiplied by a scalar. For example,

2*Q

gives

ans =

44 138 54

56 182 58

38 168 52

Note that if a variable name and the “=” sign are omitted, a variable name ans

is automatically created.

Matrix division can either be the left division operator \ or the right division

operator /. The right division a/b, for instance, is algebraically equivalent to

a

b

while the left division a\b is algebraically equivalent to

b

a

.

If Z * I = V and Z is non-singular, the left division, Z\V is equivalent to

MATLAB expression

I = inv(Z) *V

where inv is the MATLAB function for obtaining the inverse of a matrix. The

right division denoted by V/Z is equivalent to the MATLAB expression

I = V *inv(Z)

There are MATLAB functions that can be used to produce special matrices.

Examples are given in Table 1.3.

Table 1.3

Some Utility Matrices

Function

Description

ones(n,m)

Produces n-by-m matrix with all the elements being unity

eye(n)

gives n-by-n identity matrix

zeros(n,m)

Produces n-by-m matrix of zeros

diag(A)

Produce a vector consisting of diagonal of a square matrix A

No comments:

Post a Comment

THE ELETRONIKA © 2008. Design by :Yanku Templates Sponsored by: Tutorial87 Commentcute