solve
Character vector inputs have been removed. Instead, use syms to declare variables and replace inputs such as solve(‘2x == 1’,’x’) with solve(2x == 1,x).
调用格式:
S = solve(eqn,var)
solves the equation eqn for the variable var. If you do not specify var, the symvar function determines the variable to solve for. For example,solve(x + 1 == 2, x)
solves the equation x + 1 = 2 for x.S = solve(eqn,var,Name,Value)
Y = solve(eqns,vars)
Y = solve(eqns,vars,Name,Value)
[y1,...,yN] = solve(eqns,vars)
[y1,...,yN] = solve(eqns,vars,Name,Value)
[y1,...,yN,parameters,conditions] = solve(eqns,vars,'ReturnConditions',true)
栗子:
1
2
3
4
5%Use the == operator to specify the equation sin(x) == 1 and solve it.
syms x
eqn = sin(x) == 1;
solx = solve(eqn,x)
%answer:solx = pi/2