Solve Linear Equation in Matlab Programming

MATLAB Assignment Help by MATLAB Programming Expert

In mathematics, a system of linear equations (or linear system) is a group of two or more linear equations involving the same set of variables. A linear system in three variables defines a collection of planes. The intersection point is the solution of the equations. The theory of linear systems is the fundamental part of linear algebra, a subject which is used in most parts of mathematics. Computational algorithms for getting the solutions are an important part of numerical linear algebra, and play a crucial role in engineering, physics, chemistry, computer science, and economics. A system of non-linear equations can often be approximated by a linear system, a helpful technique when creating a mathematical model or computer simulation of a relatively complex system.

This section shows you how to solve a system of linear equations with the help of Symbolic Math Toolbox™.

  • Solve System of Linear Equations Using linsolve


  • Solve System of Linear Equations Using solve

Here is the procedure for solving linear equation in MATLAB

Declaration of system of equations.

syms x y z

eq1 = 2*x + y + z == 2;

eq2 = -x + y - z == 3;

eq3 = x + 2*y + 3*z == -10;

Conversion of the equations into the form AX = B. Using equationsToMatrix. The second input to equationsToMatrix defines the independent variables in the equations.

[A,B] = equationsToMatrix([eqn1, eqn2, eqn3], [x, y, z])

solve should be used instead of linsolve if the equations are in the form of expressions and not a matrix of coefficients.

2x+y+z=2

−x+y−z=3

x+2y+3z=−10

Declare the system of equations.

syms x y z

eq1 = 2*x + y + z == 2;

eq2 = -x + y - z == 3;

eq3 = x + 2*y + 3*z == -10;

Solve the system of equations using solve. The inputs give to function solve are a vector of equations, and a vector of variables to solve the equations for.

sol = solve([eqn1, eqn2, eqn3], [x, y, z]);

xSol = sol.x

ySol = sol.y

zSol = sol.z

xSol =

3

ySol =

1

zSol =

-5

solve returns the solutions in a structure array. To access the solutions, index into the array.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.