Download as pdf or txt
Download as pdf or txt
You are on page 1of 19

Chapter 2: matrix computation and linear algebra

1
Today’s outline

- Variables: short and long format


- Polar and complex representation
- vector arithmetic operations
- vector functions: linspace /logspace, max / min, sum, size/length
- matrix definition , indexing and matrix arithmetic operations
- matrix operations element by element
- matrix functions
- elementary matrices

2
Variables: short and long format
To start matlab : by double clicking on the Matlab shortcut

3
Polar and complex representation
- let’s take a complex number 

with In matlab one can write:

4
5
Vector arithmetic operations
- a row vector can be written:

6
- a column vector can be written:

- addition cannot be between column and row vectors but multiplication or


division is possible when vectors has the same number of elements:

7
8
Vector functions

9
10
Matrix definition, indexing and matrix operations
- To define matrix in matlab , we use:
Square bracket, then the element of 1rst row (separated by commes or space, we
step the second row by a semi column, …etc. then we end by the squar bracket.

Example:

- to index matrix, we use parentheses” (index row, index column)”, so that we


locate one or some elements.
11
- for sub matrix we use vectors of row and column indices: A([indexes of
rows],[indexes of columns]) or a column operator A(m:n,k:l)

12
- We can add or delete a vector or a sub-matrix. example:

13
Matrix operations element by element

14
Matrix functions
- Demision and transpose are given such as:

15
- inv  the inverse of matrix, normmatrix (or vectors) norm, rank number of
linearly independent vectors

16
- det  determinant, diag diagonal elements or A(i,i) and eig  the Eigen values

17
- repmat containing n copies of A in the row and column, triangular upper
/lower the upper / lower elements of A

18
Elementary matrices

19

You might also like