Engineering Fundamentals: An Introduction to Engineering, 4th ed.c

(Steven Felgate) #1
Example 15.6 The formulation of many engineering problems leads to a system of algebraic equations. As
you will learn later in your math and engineering classes, there are a number of ways to solve a
set of linear equations. Solve the following set of equations using the Gauss elimination, by
inverting the [A] matrix (the coefficients of unknowns), and multiplying it by {b} matrix (the
values on the right hand side of equations). The Gauss elimination method is discussed in de-
tail in Section 18.5. Here, our intent is to show how to use MATLAB to solve a set of linear
equations.

For this problem, the coefficient matrix [A] and the right-hand side matrix {b} are


We will first use the MATLAB matrix left division operator \to solve this problem. The \
operator solves the problem using the Gauss elimination. We then solve the problem using
the invcommand.



>> A = [2 1 1;3 2 4;5 -1 3]
A =
211
324
5-13

>> b = [13;32;17]
b =
13
32
17
>> x = A\b
x =
2.0000
5.0000
4.0000
>> x = inv(A)*b
x =
2.0000
5.0000
4.0000
------------------------------------------------------------

3 A 4 £


211


324


5  13


§ and 5 b 6 •


13


32


17



5 x 1 x 2  3 x 3  17


3 x 1  2 x 2  4 x 3  32


2 x 1 x 2 x 3  13


15.5 Matrix Computations with MATLAB 491


Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).

圀圀圀⸀夀䄀娀䐀䄀一倀刀䔀匀匀⸀䌀伀䴀圀圀圀⸀夀䄀娀䐀䄀一倀刀䔀匀匀⸀䌀伀䴀

Free download pdf