Matrices - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

Matrices

Description:

Matrix - Ordered set of scalars arranged in a rectangular pattern ... Inclusion of a carriage return between rows is optional. ... – PowerPoint PPT presentation

Number of Views:41
Avg rating:3.0/5.0
Slides: 18
Provided by: Walt90
Category:
Tags: matrices | pattern

less

Transcript and Presenter's Notes

Title: Matrices


1
Matrices
Matrix - Ordered set of scalars arranged in a
rectangular pattern
  • matrix with 3 rows and 3 columns
  • matrix is of order 3x3
  • matrix is a square matrix of order 3
  • matrix with 3 rows and 2 columns
  • matrix is of order 3x2

2
  • Create an m-file with the code shown.
  • Elements of a matrix are entered row-by-row with
    a semicolon separating the rows.
  • Inclusion of a carriage return between rows is
    optional.
  • Save the file in your workspace as matrix_1.m
  • Execute the program from the Command Window and
    verify the results shown.

3
  • A matrix with a single row is referred to as a
    row vector
  • A matrix with a single column is referred to as a
    column vector
  • A matrix with a single number can still be
    treated as a matrix. It is referred to as a
    scalar
  • An individual element in a matrix is identified
    by its row and column number

4
  • Add the code shown to the end of your matrix_1.m
    file.
  • Save the changes, execute the file from the
    Command Window and verify the additional output
    shown.
  • Individual elements of a matrix are identified by
    row and column numbers in parenthesis by the
    matrix name.
  • Elements of a matrix can be changed individually.
  • Example of a row vector.
  • Example of a column vector.

5
Scalar Multiplication
  • In the scalar multiplication of a matrix, each
    element of the matrix is multiplied by the same
    scalar value

6
Matrix Addition or Subtraction
  • For matrix addition (or subtraction), the
    elements of two matrices are added (or
    subtracted) on element by element basis.
  • The two matrices must be of equal order, i.e.,
    they must have the same number of rows and
    columns.
  • The result will be of the same order.

7
  • Modify matrix_1.m by adding the lines shown.
  • Save the changes, execute the program, and verify
    the additional output shown.
  • Scalar multiplication of a matrix.
  • Matrix addition.

8
Matrix Multiplication
  • For matrix multiplication, the elements in the
    rows of the first matrix are multiplied by
    elements of the columns of the second matrix and
    the products are added.
  • The matrices must have opposing order, i.e., the
    number of columns of the first matrix must equal
    the number of rows of the second matrix.
  • Result is a square matrix

9
  • Modify matrix_1.m by adding the lines shown.
  • Save the changes, execute the program and verify
    the additional output shown.
  • Matrix multiplication of a 2x3 by a 3x3
    results in a 2x3 matrix
  • Matrix multiplication of a 3x3 by a 2x3 is
    invalid and results in an error message.
  • Matrix multiplication requires matrices of
    opposing order p x mm x q
    p x q

10
Special Matrices
  • For the transpose of a matrix, the rows and
    columns are exchanged.
  • The identity matrix has 1s on the diagonal and
    0s for all of the off-diagonal elements.
  • Multiplying a matrix by the identity matrix
    yields the same original matrix.
  • Multiplying by the identity matrix is analogous
    to multiplying a scalar by one

11
Special Matrices
  • Multiplying a matrix by its inverse results in
    the identity matrix.
  • Multiplying a matrix by its inverse is analogous
    to dividing a scalar by itself the result is
    one.
  • The process for the determination of the inverse
    of a matrix is well defined but tedious. Tools
    are available to do this in Excel, Matlab, and
    Mathcad.

12
  • Modify matrix-1.m by adding the lines shown.
  • Note that to avoid generating the matrix multiply
    error, the incorrect line has been turned into an
    non-executable comment by beginning the line with
    a character.
  • Save the changes, execute the program, and verify
    the additional output shown.
  • In Matlab, the transpose of a matrix is indicated
    by adding an apostrophe after the matrix name.

13
  • Modify matrix-1.m by adding the lines shown.
  • Save the changes, execute the program, and verify
    the additional output shown.
  • The identity matrix has 1s on the diagonal and
    0s for all other elements.
  • Multiplying a matrix by the identity matrix
    yields the original matrix.

14
Solution of Linear Equation Sets
  • Linearly independent equation set

15
Solution of Linear Equation Sets
  • Multiply through by the inverse of the
    coefficient matrix
  • The left-hand side is just the vector of unknowns
  • Evaluating the right-hand side produces the
    solution

16
Solution of Linear Equation Sets
  • Perform a check by multiplying the original
    coefficient matrix by the solution vector.
  • The result should be equal to the right-hand side
    vector from the equation set.

17
  • Modify matrix_1.m by adding the lines shown.
  • Save the changes, execute the program and verify
    the additional output shown.
  • Matlab includes a built-in function for
    evaluating the inverse of a matrix, inv().
  • Note that multiplying a matrix by its inverse
    results in the identity matrix.
  • Calculate the solution for the linear equation
    set by multiplying the right-hand-side vector by
    the inverse of the coefficient matrix.
Write a Comment
User Comments (0)
About PowerShow.com