How to Solve Simultaneous Equations Using MATLAB

Written by michael carroll
  • Share
  • Tweet
  • Share
  • Pin
  • Email
How to Solve Simultaneous Equations Using MATLAB
Use "solve" to look for solutions to systems of equations in MATLAB. (Jupiterimages, Brand X Pictures/Brand X Pictures/Getty Images)

Solving systems of linear equations is an elementary topic in linear algebra, and is often encountered by high school and college students alike. MATLAB is ideally-suited to solve such simultaneous equations, provided the student is comfortable representing the equations as a matrix and using row reduction to determine the solution; these types of representations and operations are essential functions of MATLAB. However, MATLAB also has a more general equation-solving function that accepts symbolic statements of any system of equations, linear or not, and uses numerical methods if necessary. Use "solve" to quickly attempt a solution to simultaneous equations if you don't have a more specific strategy in mind.

Skill level:
Moderately Easy

Other People Are Reading


  1. 1

    Assign the results of "solve" to a single variable to produce a structure array containing the solutions to the simultaneous equations:

    solutions = solve('y=x^2','y=x')

    There are two solutions to the equations used in this example, the points (0,0) and (1,1). The array contains the values of x and y as separate entries. To see the pairs of x and y results together, type:

    [solutions.x solutions.y]

  2. 2

    Assign the results of "solve" to several variables to place the solution values directly into them:

    [x,y] = solve('y=x^2','y=x')

    The variables "x" and "y" now contain column vectors corresponding to the solutions. Place the variable names in alphabetical order in the on the left side of the assignment to make sure they receive the correct values.

  3. 3

    Specify the variable names as extra arguments if you're using symbolic constants. For example,

    [x,y] = solve('y=ax^2+bx+c','y=x','x','y')

    These results are stored symbolically, allowing you to derive an expression for the solution(s) without specifying the values of the parameters.

Don't Miss

  • All types
  • Articles
  • Slideshows
  • Videos
  • Most relevant
  • Most popular
  • Most recent

No articles available

No slideshows available

No videos available

By using the site, you consent to the use of cookies. For more information, please see our Cookie policy.