Linear Algebra Solving Simultaneous Linear Equations in MATLAB Solving SLEs with Matlab Matlab can solve some numerical SLE s A b Five techniques available:. method. method. method 4. method. method Matri Inversion The inverse of a square matri A is defined as A - Matlab can calculate matri inverse with the command, Solving SLE s by Matlab - Inverse Matlab can solve some numerical SLE s using matri inversion A b both sides by A -, A inv(a) - 0 0.0-0.00 0.0-0.00 -.000 0.00 0-0.0-0.00 0.0
Solving SLE s by Matlab Note that not all A matrices have an inverse (and not all SLE s have a unique solution!) SLE s must be for a unique solution to eist If SLE s not linearly independent, then! Matlab SLE Eample # Three simultaneous linear equations: 4 + 6 + + + 8 Equations in matri form: 6 Rank of a Matri The is the number of linearly independent rows (or columns) in the matri Matlab command is For a square matri A of order nn independent equations if consistent equations if Augmented Matri Matlab SLE Eample #: The augmented matri for the system is [ A b] [] b 6 www.engr.usask.ca/classes/ge//notes009s/lectures.ppt
Solving SLE by Matlab s rref Function Matlab s command will convert the augmented matri to its row-reduced echelon form: >> ans 0 0 0 0-0 0 4 Solving Linear Equations Consider the set of equations A b Ais an n m matri, is an m vector and b is an n vector The rank of a matri is the number of independent rows (or columns). Rank can be checked using the MATLAB command rank Equations are consistent if independent if www.engr.usask.ca/classes/ge//notes009s/lectures.ppt Linear Equations, n m Linear Equations, n < m When A is square (i.e., n m) and the equations are independent and consistent, the solution can be found using the operator. MATLAB finds the solution using a LU decomposition of A. >> A [ ; 4 6; 8 0] A 4 6 8 0 >> b [66; 804; ] b 66 804 >> [rank(a) rank([a b])] ans >> When the number of equations is less than the number of unknowns (i.e., n < m), usually an infinite number of solutions eist. \ finds the solution with >> A [ 4; ]; b [4;]; >> A\b
When there are more equations than unknowns (i.e., n > m), usually no solution eists. \ can be used to find Linear Equations, n > m >> A [ -; ; 6 - ]; >> b [; ; -]; >> [rank(a) rank([a b])] ans >> Matlab s linsolve Function Matlab s linsolve function solves finds the solution of a linear system using with row pivoting (if the A matri is square): Equations in matri form: >> 4 8 6 Non-Independent Equations Consider the following linear system with only independent equations: Non-Independent Equations 4 6 4 The rank of [A] will be? The rank of [A b] will be? www.engr.usask.ca/classes/ge//notes009s/lectures.ppt www.engr.usask.ca/classes/ge//notes009s/lectures.ppt
Non-Independent Equations Solve this set of simultaneous linear equations using each of the 4 Matlab techniques:. inverse. rref. \ ( backslash ) 4. linsolve 4 6 4 Condition The solution technique y A b produces the correct answer when Ayb is Ayb is well-conditioned when Eistence: Uniqueness: Stability: is continuous A Ayb is if it is not well-conditioned www.ncsu.edu/crsc/events/ugw0/slides/samuels_inverse.ppt What is an ill-conditioned system? Ill-Conditioned System: A system is ill-conditioned if Ill-conditioned system: 0.8 0. 0.8 0. 0.66 y 0.68 0.66 y 0.06 A y b 0.66 y 0.68 0.66 y 0.066 A y b y y y y www.ncsu.edu/crsc/events/ugw0/slides/samuels_inverse.ppt www.ncsu.edu/crsc/events/ugw0/slides/samuels_inverse.ppt
Symbolic Solution of Simultaneous Linear Equations in Matlab Symbolic Solution of Simultaneous Linear Equations in Matlab Solve: - y + 4z y + 4z + 0 -z + + 4y 0:. clear,. eq'*-. eq'y+4*z 4. eq'-*z+*. [,y,z]solve( ), y, z Note: while the symbols in the equations can be in any order (unlike MATLAB's numerical methods), the results are given in alphabetical order so you must be careful what you put inside the brackets. How do you convert to floating point numeric format? people.clarkson.edu/~wilco/es00/sym.ppt people.clarkson.edu/~wilco/es00/sym.ppt Additional Resources www.mathworks.com/access/helpdesk/help/techdoc/inde.html inv mldivide ( \ ) rref linsolve for more information on solving special cases of SLE s, look at linear systems of equations SLE s from Dynamics Use Matlab to solve the following set of SLE s from Dynamics for a A, a B, a C, T, and T a B + ac A + a 0 0kg a + A T 490N T T 0 0kg a + B T 96N 0kg a + C T 94N Note the units for a s and T s! T A W A 490N B T T W B 96N T C W C 94N
SLE s from Circuits Nine unknowns: i, i i, 6 K V, V, V A B C 00V 0Ω i 00V 0Ω i V A V B 0Ω i V A V C Ω i 4 V B V C i 0Ω i i V A V B V A 0Ω 0Ω 0Ω i V 0 i i 4 Ω i 6 B 40Ω i6 V 0 i + i i i4 i 4 + i i6 i + i C 0Ω V C 40Ω Find all pin reaction forces if P 0lb and Q 960 lb SLE s from Statics 0 in CY in CX in P 0 Multi-force members: B X C X 0 B C Q in 6in 0in in 0in in in A X + C X A + C Y Y Y Y 0 P in Q + in C + in C 0 X Y SLE s in Heat Transfer SLE s in Heat Transfer Governing PDE: PDE solution for each finite element is represented using polynomials. Collection of element solutions leads to a very large set of simultaneous linear equations: What is T(,y), given prescribed conditions on the boundary? www.mece.ualberta.ca/courses/mec6/proe_library/me68_.ppt where K is called STIFFNESS matri, is vector of unknowns at each node, and F is due to applied loads and/or boundary conditions. www.mece.ualberta.ca/courses/mec6/proe_library/me68_.ppt