Presentation is loading. Please wait.

Presentation is loading. Please wait.

ENE 206 - MATHLAB ® Lecture 3: Matrix Review. Determinant  To use MATLAB to compute determinants:  Enter the determinant as an array.  Use ‘det’ command.

Similar presentations


Presentation on theme: "ENE 206 - MATHLAB ® Lecture 3: Matrix Review. Determinant  To use MATLAB to compute determinants:  Enter the determinant as an array.  Use ‘det’ command."— Presentation transcript:

1 ENE 206 - MATHLAB ® Lecture 3: Matrix Review

2 Determinant  To use MATLAB to compute determinants:  Enter the determinant as an array.  Use ‘det’ command to evaluate the determinant. >> A = [1 2; 3 4] A = 1 2 3 4 >> det(A) ans = -2

3 Inverse matrix  To compute the inverse of the matrix, the command ‘inv’ is used.  For example, we have two equations: 2x + 9y=5 and 3x - 4y = 7. Solve these equations using the matrix inverse method. (x = A -1 b) A = [2 9; 3 -4]; b = [5;7]; x = inv(A)*b x = 2.3714 0.0286

4 The Left-Division Method  The inverse matrix method works only if the matrix A is square (the number of unknowns equals the number of equation).  Even if A is square, the method does not work for singular matrix (|A| = 0).  MATLAB provides another method to solve the equation Ax = b based on ‘Gauss elimination’ called ‘the left-division method’.  The LDM uses fewer internal multiplications and divisions; therefore, it is faster and more accurate than the matrix inverse.

5 The Left-Division Method  To use the LDM to solve for x, type ‘x = A\b’.  This works for some cases where the number of unknowns does not equal the number of equations.  Anyway, simply check first to see if |A|  0 before using any of these methods.  If |A|= 0 or if the number of equations does not equal the number of unknowns, it will be in a case of ‘underdetermined systems.’

6 Underdetermined system  This system does not contain enough information to solve for all unknown variables.  The matrix inverse method and Cramer’s method will not work.  When there are more equations than unknowns, the LDM will give a solution with some of the unknowns being set equal to zero.

7 Underdetermined system  For example, x + 3y = 6. Actually, an infinite number of solutions satisfy this equation.  By using the LDM method, the solutions will be: A = [1 3]; b = 6; x = A\b x = 0 (x = 0) 2 (y = 2)

8 Matrix Rank  An m x n matrix A has a rank r  1 if and only if |A| contains a nonzero r x r determinant and every square sub-determinant with r + 1 or more is zero.  For example, A = [3 -4 1; 6 10 2; 9 -7 3]; D =det (A) R = rank (A) D = 0 R = 2

9 Unique solutions  The set Ax = b with m equations and n unknowns has solutions if and only if rank[A] = rank[A b].  Let r = rank[A] and rank[A] = rank[A b]:  If r = n, then the solution is unique.  If r < n, an infinite number of solutions exists and r unknown variables can be expressed as linear combinations of the other n – r unknown variables, whose values are arbitrary.

10 Example of unique solution  Determine whether the following set has a unique solution, and if so, find it:  3x – 2y + 8z = 48  -6x + 5y + z = -12  9x + 4y +2z = 24

11 Example of unique solution A = [3 -2 8; -6 5 1; 9 4 2]; b = [48;-12;24]; R = rank (A) Rab = rank ([A b]) x = A\b R = 3 Rab = 3 x = 2.0000 5.0000

12 TO BE CONTINUED….


Download ppt "ENE 206 - MATHLAB ® Lecture 3: Matrix Review. Determinant  To use MATLAB to compute determinants:  Enter the determinant as an array.  Use ‘det’ command."

Similar presentations


Ads by Google