Chap#2_Matrix_and_Linear_Algerbra_part1
Chap#2_Matrix_and_Linear_Algerbra_part1
Dr. A. AMMAR
1. Matrix generation
2. Matrix manipulation and operation
3. Solving linear equations
4. Polynomials Represented by Vectors
Matrices are the basic elements of the MATLAB environment. A matrix is a two-
The elements of vectors in MATLAB are enclosed by square brackets and are
separated by spaces or by commas. For example, to enter a row vector, v, type
Column vectors are created in a similar way, however, semicolon (;) must separate
the components of a column vector,
Thus, w(1) is the first element of vector w, w(2) its second element, and so forth.
Examples
MATLAB provides a number of special matrices (see Table 2.5). These matrices
have interesting properties that make them useful for constructing examples and
for testing algorithms (Table.2).
The MATLAB command to compute the inverse of a matrix is inv(). For example,
We select elements in a matrix just as we did for vectors, but now we need two
indices. The element of row i and column j of the matrix A is denoted by A(i,j). Thus,
A(i,j) in MATLAB refers to the element Aij of matrix A. The first index is the row
number and the second index is the column number. For example, A(1,3) is an
element of first row and third column. Here, A(1,3)=3
To extract a submatrix B consisting of rows 2 and 3 and columns 1 and 2 of the matrix
A, do the following:
To interchange rows 1 and 2 of A, use the vector of row indices together with the
colon operator.
To determine the dimensions of a matrix or vector, use the command size. For
example