Download presentation

1
**Matrix Mathematics in MATLAB and Excel**

Chapter 7 Matrix Mathematics Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.

2
**Review: Multiplication of Matrices**

To multiple two matrices together, the matrices must have compatible sizes: This multiplication is possible only if the number of columns in A is the same as the number of rows in B The resultant matrix C will have the same number of rows as A and the same number of rows as B Engineering Computation: An Introduction Using MATLAB and Excel

3
**Review: Multiplication of Matrices**

Easy way to remember rules for multiplication: These values must match Size of Product Matrix Engineering Computation: An Introduction Using MATLAB and Excel

4
**Review: Multiplication of Matrices**

Element ij of the product matrix is computed by multiplying each element of row i of the first matrix by the corresponding element of column j of the second matrix, and summing the results In general, matrix multiplication is not commutative: AB ≠ B A Engineering Computation: An Introduction Using MATLAB and Excel

5
**Practice Problem Find C = A B (2 X 4) X (4 X 3) = (2 X 3)**

Engineering Computation: An Introduction Using MATLAB and Excel

6
Review: Transpose The transpose of a matrix by switching its row and columns The transpose of a matrix is designated by a superscript T: The transpose can also be designated with a prime symbol (A’). This is the nomenclature used in MATLAB Engineering Computation: An Introduction Using MATLAB and Excel

7
Review: Determinate The determinate of a square matrix is a scalar quantity that has some uses in matrix algebra. Finding the determinate of 2 × 2 and 3 × 3 matrices can be done relatively easily: The determinate is designated as |A| or det(A) 2 × 2: Engineering Computation: An Introduction Using MATLAB and Excel

8
**Review: Inverse Some square matrices have an inverse**

If the inverse of a matrix exists (designated by -1 superscript), then where I is the identity matrix – a square matrix with 1’s as the diagonal elements and 0’s as the other elements The inverse of a square matrix exists only of the determinate is non-zero Engineering Computation: An Introduction Using MATLAB and Excel

9
**Matrix Operations in Excel**

Excel has commands for: Multiplication (mmult) Transpose (transpose) Determinate (mdeterm) Inverse (minverse) Important to remember that these commands apply to an array of cells instead of to a single cell When entering the command, you must identify the entire array where the answer will be displayed Engineering Computation: An Introduction Using MATLAB and Excel

10
**Excel Matrix Multiplication**

Repeat previous problem – first enter the two matrices: Engineering Computation: An Introduction Using MATLAB and Excel

11
**Excel Matrix Multiplication**

Good practice to label the matrices: Engineering Computation: An Introduction Using MATLAB and Excel

12
**Excel Matrix Multiplication**

Shading and borders help the matrices stand out: Engineering Computation: An Introduction Using MATLAB and Excel

13
**Excel Matrix Multiplication**

Array of cells for the product must be selected – in this case, a 2 × 3 array: Engineering Computation: An Introduction Using MATLAB and Excel

14
**Excel Matrix Multiplication**

The MMULT function has two arguments: the ranges of cells to be multiplied. Remember that the order of multiplication is important. Engineering Computation: An Introduction Using MATLAB and Excel

15
**Excel Matrix Multiplication**

Using the Enter key with an array command only returns an answer in a single cell. Instead, use Ctrl + Shift + Enter keys with array functions Engineering Computation: An Introduction Using MATLAB and Excel

16
**Excel Matrix Multiplication**

Answer cells formatted: Engineering Computation: An Introduction Using MATLAB and Excel

17
**Excel Transpose Use Ctrl + Shift + Enter to input command**

Engineering Computation: An Introduction Using MATLAB and Excel

18
Excel Determinate Since determinate is a scalar, select a single cell and use Enter to input command Engineering Computation: An Introduction Using MATLAB and Excel

19
**Excel Matrix Inversion**

Remember that only square matrices can have inverses Engineering Computation: An Introduction Using MATLAB and Excel

20
**Excel Matrix Inversion**

Ctrl + Shift + Enter to input command Engineering Computation: An Introduction Using MATLAB and Excel

21
**Check: A X A-1 = I, the identity matrix:**

Engineering Computation: An Introduction Using MATLAB and Excel

22
**Matrix Operations in MATLAB**

Matrices are easily handled in MATLAB We will look at commands for: Multiplication Transpose Determinate Inverse Engineering Computation: An Introduction Using MATLAB and Excel

23
MATLAB Matrix Input Recall that to enter matrices in MATLAB, the elements are enclosed in square brackets Spaces or commas separate element within a row; semi-colons separate rows >> G = [2 5 8; ; 3 1 2] G = Engineering Computation: An Introduction Using MATLAB and Excel

24
**MATLAB Matrix Multiplication**

>> G = [2 5 8; ; 3 1 2] G = >> H = [4 5; 6 12; 1 1] H = Matrix multiplication symbol is same as for scalar multiplication (*): >> L = G*H L = Engineering Computation: An Introduction Using MATLAB and Excel

25
**Repeat Earlier Example**

Find C = A B >> A = [ ; ]; >> B = [2 3 1;0 1 0; ; 2 2 1]; >> C = A*B C = Engineering Computation: An Introduction Using MATLAB and Excel

26
MATLAB Transpose The transpose command switches rows and columns of a matrix: >> A = [10 6; 12 9; 1 3; 0 1] A = >> B = transpose(A) B = Engineering Computation: An Introduction Using MATLAB and Excel

27
MATLAB Transpose Shortcut: The prime symbol (') after a matrix also performs the tranposition: >> A = [10 6; 12 9; 1 3; 0 1] A = >> B = A' B = Engineering Computation: An Introduction Using MATLAB and Excel

28
MATLAB Determinate The det command finds the determinate of a square matrix: >> A = [2 5 6; ; 3 2 2] A = >> B = det(A) B = 53 Engineering Computation: An Introduction Using MATLAB and Excel

29
**MATLAB Inversion The inv command finds the inverse of a square matrix:**

>> B = inv(A) B = Engineering Computation: An Introduction Using MATLAB and Excel

30
**Check: >> C = A*B C = 1.0000 0 -0.0000 0.0000 1.0000 -0.0000**

Product of a matrix and its inverse is the identity matrix Engineering Computation: An Introduction Using MATLAB and Excel

31
**MATLAB Matrix Inversion**

Another example: A = >> B = inv(A) Warning: Matrix is singular to working precision. B = Inf Inf Inf Can you guess why this matrix has no inverse? What is the determinate of A? Engineering Computation: An Introduction Using MATLAB and Excel

32
**MATLAB Matrix Inversion**

Note that the third row of the matrix is simply the first row multiplied by a constant (2). When this happens, the matrix is singular and has no inverse. Also, notice that the determinate of the matrix is zero: >> det(A) ans = Engineering Computation: An Introduction Using MATLAB and Excel

33
**Linear Simultaneous Equations**

Consider an equation with three unknowns x, y, and z If the equation contains only linear terms of x, y, and z – that is, only constants multiplied by each variable – and constants, then the equation is linear If the equation contains any terms such as x2, cos(x), ex, etc., then the equation is non-linear Engineering Computation: An Introduction Using MATLAB and Excel

34
**Linear Simultaneous Equations**

Example of a linear equation: With what we know about multiplying matrices, we can write this equation as: (1 X 3) X (3 X 1) = (1 x 1) Engineering Computation: An Introduction Using MATLAB and Excel

35
**Linear Simultaneous Equations**

Let’s add a second equation: We can add this to our previous matrix equation by adding a second row to the first matrix and to the product: (2 X 3) X (3 X 1) = (1 x 2) Engineering Computation: An Introduction Using MATLAB and Excel

36
**Linear Simultaneous Equations**

Finally, let’s add a third equation: Our matrix equation is now: (3 X 3) X (3 X 1) = (1 x 3) Engineering Computation: An Introduction Using MATLAB and Excel

37
**Linear Simultaneous Equations**

We will use matrix mathematics to solve the equations for x, y, and z The first step in solving a series of linear simultaneous equations is to write them in matrix form For n simultaneous equations and n unknowns: where A is the coefficient matrix (n × n); X is the matrix of unknowns (n × 1), and C is the constant matrix (n × 1) Engineering Computation: An Introduction Using MATLAB and Excel

38
**Linear Simultaneous Equations**

Recall that if there are more unknowns then equations, then we cannot find a unique solution If there are more equations than unknowns, then some equations must be redundant If there are exactly the same number of equations and unknowns, then there may be a unique solution. In this case the coefficient matrix will be square Engineering Computation: An Introduction Using MATLAB and Excel

39
**Practice Write these four equations in matrix form:**

Engineering Computation: An Introduction Using MATLAB and Excel

40
Solution In Chapter 8, we will learn how to find the unknowns a, b, c, and d with matrix methods Engineering Computation: An Introduction Using MATLAB and Excel

Similar presentations

© 2020 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google