1 / 7

MATLAB: Simultaneous Equations

MATLAB: Simultaneous Equations. Lecture 22. Simultaneous Equations with MATLAB.

Download Presentation

MATLAB: Simultaneous Equations

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. MATLAB: Simultaneous Equations Lecture 22 Winter Quarter

  2. Simultaneous Equations with MATLAB • MATLAB is very powerful for solving systems of N equations with N unknowns. It is used extensively for analyzing electric power grids and circuits, fluid flow in piping systems, and other engineering applications. It can, of course, be used for any application with n equations and n unknowns. • For example, suppose that a Calculus text (C), a Physics text (P) and a Graphics text (G) can be purchased for $146. Then suppose the Calculus and Graphics texts can be purchased for $87 and the Physics and Calculus texts can be purchased for $105. How much does each text cost? Winter Quarter

  3. The problem can be written as: 1P + 1C + 1G = 146 1C + 1G = 87 1P + 1C = 105 In MATLAB, the coefficients of the variables P, C & G are placed in a matrix and the Dollar values in a column vector. >>Books=[1,1,1;0,1,1;1,1,0] Books = 1 1 1 0 1 1 1 1 0 >>Dollars=[146;87;105] Dollars = 146 87 105 Simultaneous Equations with MATLAB Winter Quarter

  4. Simultaneous Equations with MATLAB • Now, the inverse of the matrix Books is multiplied by the vector Dollars: >>Cost = inv (Books) * Dollars Cost = 59 46 41 • This vector contains the cost of P in row one, C in row 2 and G in row 3. Winter Quarter

  5. Simultaneous Equations with MATLAB • Another MATLAB solution would be to use the reverse division sign as follows: >>Cost = Books \ Dollars Cost = 59 46 41 Winter Quarter

  6. Simultaneous Equations with MATLAB • A third MATLAB solution can be obtained by using the Row Reduced Echelon Form (rref) function as follows. First combine the matrix and vector: EDU» COMBINED=[Books Dollars] COMBINED = 1 1 1 146 0 1 1 87 1 1 0 105 Winter Quarter

  7. Simultaneous Equations with MATLAB • Then invoke the rref function with the resulting matrix. >> Cost = rref (COMBINED) Cost = 1 0 0 59 0 1 0 46 0 0 1 41 • The last column in the new matrix is the cost vector. Winter Quarter

More Related