Matrix Mathematics in MATLAB and Excel

Slides:



Advertisements
Similar presentations
Matrix Algebra Matrix algebra is a means of expressing large numbers of calculations made upon ordered sets of numbers. Often referred to as Linear Algebra.
Advertisements

Matrices: Inverse Matrix
1 Copyright © 2015, 2011, 2007 Pearson Education, Inc. Chapter 4-1 Systems of Equations and Inequalities Chapter 4.
MF-852 Financial Econometrics
Chapter 2 Basic Linear Algebra
Matrix Commands in Excel Anthony Murphy Nuffield College
MOHAMMAD IMRAN DEPARTMENT OF APPLIED SCIENCES JAHANGIRABAD EDUCATIONAL GROUP OF INSTITUTES.
Part 3 Chapter 8 Linear Algebraic Equations and Matrices PowerPoints organized by Dr. Michael R. Gustafson II, Duke University All images copyright © The.
Linear Simultaneous Equations
Pam Perlich Urban Planning 5/6020
Finding the Inverse of a Matrix
CE 311 K - Introduction to Computer Methods Daene C. McKinney
Copyright © Cengage Learning. All rights reserved. 7.6 The Inverse of a Square Matrix.
Non-Linear Simultaneous Equations
1 Chapter 3 Matrix Algebra with MATLAB Basic matrix definitions and operations were covered in Chapter 2. We will now consider how these operations are.
1 Chapter 2 Matrices Matrices provide an orderly way of arranging values or functions to enhance the analysis of systems in a systematic manner. Their.
Chapter 7 Matrix Mathematics Matrix Operations Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display.
Chapter 2 Systems of Linear Equations and Matrices Section 2.4 Multiplication of Matrices.
Mathematics of Cryptography Part I: Modular Arithmetic, Congruence,
Computer Programming (TKK-2144) 13/14 Semester 1 Instructor: Rama Oktavian Office Hr.: M.13-15, W Th , F
Chapter 10 Review: Matrix Algebra
3.5 Solution by Determinants. The Determinant of a Matrix The determinant of a matrix A is denoted by |A|. Determinants exist only for square matrices.
Chapter 2 Solving Linear Systems Matrix Definitions –Matrix--- Rectangular array/ block of numbers. –The size/order/dimension of a matrix: (The numbers.
ECON 1150 Matrix Operations Special Matrices
Matrices Square is Good! Copyright © 2014 Curt Hill.
 Row and Reduced Row Echelon  Elementary Matrices.
Barnett/Ziegler/Byleen Finite Mathematics 11e1 Review for Chapter 4 Important Terms, Symbols, Concepts 4.1. Systems of Linear Equations in Two Variables.
Presentation by: H. Sarper
CSE123 Lecture 5 Arrays and Array Operations. Definitions Scalars: Variables that represent single numbers. Note that complex numbers are also scalars,
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
Chapter 4 Matrices By: Matt Raimondi.
Copyright © 2013, 2009, 2005 Pearson Education, Inc. 1 5 Systems and Matrices Copyright © 2013, 2009, 2005 Pearson Education, Inc.
CMPS 1371 Introduction to Computing for Engineers MATRICES.
8.1 Matrices & Systems of Equations
Matrices Addition & Subtraction Scalar Multiplication & Multiplication Determinants Inverses Solving Systems – 2x2 & 3x3 Cramer’s Rule.
Copyright © 2013, 2009, 2005 Pearson Education, Inc. 1 5 Systems and Matrices Copyright © 2013, 2009, 2005 Pearson Education, Inc.
Lecture 28: Mathematical Insight and Engineering.
1 C ollege A lgebra Systems and Matrices (Chapter5) 1.
Unit 6 : Matrices.
Working with Arrays in MATLAB
ES 240: Scientific and Engineering Computation. Chapter 8 Chapter 8: Linear Algebraic Equations and Matrices Uchechukwu Ofoegbu Temple University.
Slide Copyright © 2009 Pearson Education, Inc. 7.3 Matrices.
ME 142 Engineering Computation I Matrix Operations in Excel.
INTRODUCTION TO MATLAB DAVID COOPER SUMMER Course Layout SundayMondayTuesdayWednesdayThursdayFridaySaturday 67 Intro 89 Scripts 1011 Work
MT411 Robotic Engineering Asian Institution of Technology (AIT) Chapter 1 Introduction to Matrix Narong Aphiratsakun, D.Eng.
Matrices Digital Lesson. Copyright © by Houghton Mifflin Company, Inc. All rights reserved. 2 A matrix is a rectangular array of real numbers. Each entry.
TH EDITION LIAL HORNSBY SCHNEIDER COLLEGE ALGEBRA.
Copyright © 2011 Pearson Education, Inc. Publishing as Prentice Hall Chapter 5 More Work with Matrices
Matrices and Matrix Operations. Matrices An m×n matrix A is a rectangular array of mn real numbers arranged in m horizontal rows and n vertical columns.
MATRIX A set of numbers arranged in rows and columns enclosed in round or square brackets is called a matrix. The order of a matrix gives the number of.
2.5 – Determinants and Multiplicative Inverses of Matrices.
Finishing up Chapter 5. Will this code enter the if statement? G=[30,55,10] if G
Matrix Algebra Basics Chapter 3 Section 5. Algebra.
If A and B are both m × n matrices then the sum of A and B, denoted A + B, is a matrix obtained by adding corresponding elements of A and B. add these.
Designed by Victor Help you improve MATRICES Let Maths take you Further… Know how to write a Matrix, Know what is Order of Matrices,
Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 1 Part 3 - Chapter 8 Linear Algebraic Equations and Matrices.
10.4 Matrix Algebra. 1. Matrix Notation A matrix is an array of numbers. Definition Definition: The Dimension of a matrix is m x n “m by n” where m =
Matrices Introduction.
College Algebra Chapter 6 Matrices and Determinants and Applications
Linear Algebraic Equations and Matrices
CGN 2420 Matrix Operations in Excel
Chapter 7 Matrix Mathematics
Linear Algebraic Equations and Matrices
Matrix Algebra.
MATRICES MATRIX OPERATIONS.
Method 1: Substitution methods
Matrix Algebra.
Rayat Shikshan Sanstha’s S.M.Joshi College, Hadapsar -28
MATRICES MATRIX OPERATIONS.
Solving Linear Systems of Equations - Inverse Matrix
Presentation transcript:

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

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

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

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

Practice Problem Find C = A B (2 X 4) X (4 X 3) = (2 X 3) Engineering Computation: An Introduction Using MATLAB and Excel

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

Check: A X A-1 = I, the identity matrix: Engineering Computation: An Introduction Using MATLAB and Excel

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

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; -1 9 10; 3 1 2] G = 2 5 8 -1 9 10 3 1 2 Engineering Computation: An Introduction Using MATLAB and Excel

MATLAB Matrix Multiplication >> G = [2 5 8; -1 9 10; 3 1 2] G = 2 5 8 -1 9 10 3 1 2 >> H = [4 5; 6 12; 1 1] H = 4 5 6 12 1 1 Matrix multiplication symbol is same as for scalar multiplication (*): >> L = G*H L = 46 78 60 113 20 29 Engineering Computation: An Introduction Using MATLAB and Excel

Repeat Earlier Example Find C = A B >> A = [3 5 1 0; 2 -2 1 -1]; >> B = [2 3 1;0 1 0; -1 2 5; 2 2 1]; >> C = A*B C = 5 16 8 1 4 6 Engineering Computation: An Introduction Using MATLAB and Excel

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

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

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

MATLAB Inversion The inv command finds the inverse of a square matrix: 2 5 6 -1 0 5 3 2 2 >> B = inv(A) B = -0.1887 0.0377 0.4717 0.3208 -0.2642 -0.3019 -0.0377 0.2075 0.0943 Engineering Computation: An Introduction Using MATLAB and Excel

Check: >> C = A*B C = 1.0000 0 -0.0000 0.0000 1.0000 -0.0000 1.0000 0 -0.0000 0.0000 1.0000 -0.0000 0 -0.0000 1.0000 Product of a matrix and its inverse is the identity matrix Engineering Computation: An Introduction Using MATLAB and Excel

MATLAB Matrix Inversion Another example: A = 3 4 1 5 -2 2 6 8 2 >> 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

MATLAB Matrix Inversion 3 4 1 5 -2 2 6 8 2 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

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

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

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

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

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

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

Practice Write these four equations in matrix form: Engineering Computation: An Introduction Using MATLAB and Excel

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