| Products & Services | Solutions | Academia | Support | User Community | Company |
| Download Product Updates | | | Get Pricing | | | Trial Software |
| Documentation → Symbolic Math Toolbox |
| Contents | Index |
| Learn more about Symbolic Math Toolbox |
solve(eq)
solve(eq, var)
solve(eq1, eq2, ..., eqn)
g = solve(eq1, eq2, ..., eqn, var1, var2, ..., varn)
The input to solve can be either symbolic expressions or strings. If eq is a symbolic expression (x^2 - 2*x + 1) or a string that does not contain an equal sign ('x^2 - 2*x + 1'), then solve(eq) solves the equation eq = 0 for its default variable (as determined by symvar).
solve(eq, var) solves the equation eq (or eq = 0 in the two cases cited above) for the variable var.
The inputs are either symbolic expressions or strings specifying equations. solve(eq1, eq2, ..., eqn) or solves the system of equations implied by eq1,eq2,...,eqn in the n variables determined by applying symvar to the system.
g = solve(eq1, eq2, ..., eqn, var1, var2, ..., varn) finds the zeros for the system of equations for the variables specified as inputs.
Three different types of output are possible. For one equation and one output, the resulting solution is returned with multiple solutions for a nonlinear equation. For a system of equations and an equal number of outputs, the results are sorted alphabetically and assigned to the outputs. For a system of equations and a single output, a structure containing the solutions is returned.
For both a single equation and a system of equations, numeric solutions are returned if symbolic solutions cannot be determined.
Solve the quadratic equation:
syms a b c x;
solve('a*x^2 + b*x + c')The result is:
ans = -(b + (b^2 - 4*a*c)^(1/2))/(2*a) -(b - (b^2 - 4*a*c)^(1/2))/(2*a)
Solve the quadratic equation for the variable b:
syms a b c x;
solve('a*x^2 + b*x + c','b')The result is:
ans = -(a*x^2 + c)/x
Solve the system of equations:
syms x;
S = solve('x + y = 1','x - 11*y = 5');
S = [S.x S.y]The result is:
S = [ 4/3, -1/3]
The statement
syms a u v;
A = solve('a*u^2 + v^2', 'u - v = 1', 'a^2 - 5*a + 6')returns
A =
a: [4x1 sym]
u: [4x1 sym]
v: [4x1 sym]To see the elements of A, enter:
Aa = A.a Au = A.u Av = A.v
Aa = 3 2 2 3 Au = (3^(1/2)*i)/4 + 1/4 (2^(1/2)*i)/3 + 1/3 1/3 - (2^(1/2)*i)/3 1/4 - (3^(1/2)*i)/4 Av = (3^(1/2)*i)/4 - 3/4 (2^(1/2)*i)/3 - 2/3 - (2^(1/2)*i)/3 - 2/3 - (3^(1/2)*i)/4 - 3/4
Arithmetic Operations, dsolve, symvar
![]() | size (sym) | sort (sym) | ![]() |

Includes the most popular MATLAB recorded presentations with Q&A sessions led by MATLAB experts.
| © 1984-2009- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |