matlab中solve函数的用法。悬赏20分 15
我编了一个求三元二次方程组的程序(matlab)[x1,x2,x3]=solve('x1*x1*1+x1*x2*5+x1*x3*3+x2*x1*5+x2*x2*29+x2...
我编了一个求三元二次方程组的程序(matlab)[x1,x2,x3]=solve('x1*x1*1+x1*x2*5+x1*x3*3+x2*x1*5+x2*x2*29+x2*x3*23+x3*x1*3+x3*x2*23+x3*x3*25+13-(2*x1*3+2*x2*19+2*x3*17)=0','x1+x2+x3=1','0<x1<1','0<x2<1','0<x3_<%</x1<1','0<x2<1','0<x3
展开
1个回答
展开全部
solve Symbolic solution of algebraic equations.
solve('eqn1','eqn2',...,'eqnN')
solve('eqn1','eqn2',...,'eqnN','var1,var2,...,varN')
solve('eqn1','eqn2',...,'eqnN','var1','var2',...'varN')
The eqns are symbolic expressions or strings specifying equations. The
vars are symbolic variables or strings specifying the unknown variables.
solve seeks zeros of the expressions or solutions of the equations.
If not specified, the unknowns in the system are determined by SYMVAR.
If no analytical solution is found and the number of equations equals
the number of dependent variables, a numeric solution is attempted.
Three different types of output are possible. For one equation and one
output, the resulting solution is returned, with multiple solutions to
a nonlinear equation in a symbolic vector. For several equations and
an equal number of outputs, the results are sorted in lexicographic
order and assigned to the outputs. For several equations and a single
output, a structure containing the solutions is returned.
solve(...,'IgnoreAnalyticConstraints',VAL) controls the level of
mathematical rigor to use on the analytical constraints of the solution
(branch cuts, division by zero, etc). The options for VAL are TRUE or
FALSE. Specify FALSE to use the highest level of mathematical rigor
in finding any solutions. The default is FALSE.
solve(...,'PrincipalValue',VAL) controls whether solve should return
multiple solutions, including parameterized infinite solution sets
(if VAL is FALSE), or just a single solution (when VAL is TRUE).
The default is FALSE.
solve(...,'IgnoreProperties',VAL) controls if solve should take
assumptions on variables into account. VAL can be TRUE or FALSE.
The default is FALSE (i.e., take assumptions into account).
solve(...,'Real',VAL) allows to put the solver into "real mode."
In "real mode," only real solutions such that all intermediate values
of the input expression are real are searched. VAL can be TRUE
or FALSE. The default is FALSE.
solve(...,'MaxDegree',n) controls the maximum degree of polynomials
for which explicit formulas will be used during the computation.
n must be a positive integer smaller than 5. The default is 3.
Examples:
solve('p*sin(x) = r') chooses 'x' as the unknown and returns
ans =
asin(r/p)
pi - asin(r/p)
[x,y] = solve('x^2 + x*y + y = 3','x^2 - 4*x + 3 = 0') returns
x =
1
3
y =
1
-3/2
S = solve('x^2*y^2 - 2*x - 1 = 0','x^2 - y^2 - 1 = 0') returns
the solutions in a structure.
S =
x: [8x1 sym]
y: [8x1 sym]
[u,v] = solve('a*u^2 + v^2 = 0','u - v = 1') regards 'a' as a
parameter and solves the two equations for u and v.
S = solve('a*u^2 + v^2','u - v = 1','a,u') regards 'v' as a
parameter, solves the two equations, and returns S.a and S.u.
[a,u,v] = solve('a*u^2 + v^2','u - v = 1','a^2 - 5*a + 6') solves
the three equations for a, u and v.
S = solve('x^(5/2) = 8^(10/3)') returns all three complex solutions:
S =
16
- 4*5^(1/2) - 4 + 4*2^(1/2)*(5 - 5^(1/2))^(1/2)*i
- 4*5^(1/2) - 4 - 4*2^(1/2)*(5 - 5^(1/2))^(1/2)*i
S = solve('x^(5/2) = 8^(10/3)', 'PrincipalValue', true) selects one of these:
S =
- 4*5^(1/2) - 4 + 4*2^(1/2)*(5 - 5^(1/2))^(1/2)*i
S = solve('x^(5/2) = 8^(10/3)', 'IgnoreAnalyticConstraints', true)
ignores branch cuts during internal simplifications and, in this case,
also returns only one solution:
S =
16
syms t positive
solve(t^2-1)
ans =
1
solve(t^2-1, 'IgnoreProperties', true)
ans =
1
-1
solve(x^3-1) returns all three complex roots:
ans =
1
- 1/2 + (3^(1/2)*i)/2
- 1/2 - (3^(1/2)*i)/2
solve(x^3-1, 'Real', true) only returns the real root:
ans =
1
这是具体的用法,注意变量的选取。。。
solve('eqn1','eqn2',...,'eqnN')
solve('eqn1','eqn2',...,'eqnN','var1,var2,...,varN')
solve('eqn1','eqn2',...,'eqnN','var1','var2',...'varN')
The eqns are symbolic expressions or strings specifying equations. The
vars are symbolic variables or strings specifying the unknown variables.
solve seeks zeros of the expressions or solutions of the equations.
If not specified, the unknowns in the system are determined by SYMVAR.
If no analytical solution is found and the number of equations equals
the number of dependent variables, a numeric solution is attempted.
Three different types of output are possible. For one equation and one
output, the resulting solution is returned, with multiple solutions to
a nonlinear equation in a symbolic vector. For several equations and
an equal number of outputs, the results are sorted in lexicographic
order and assigned to the outputs. For several equations and a single
output, a structure containing the solutions is returned.
solve(...,'IgnoreAnalyticConstraints',VAL) controls the level of
mathematical rigor to use on the analytical constraints of the solution
(branch cuts, division by zero, etc). The options for VAL are TRUE or
FALSE. Specify FALSE to use the highest level of mathematical rigor
in finding any solutions. The default is FALSE.
solve(...,'PrincipalValue',VAL) controls whether solve should return
multiple solutions, including parameterized infinite solution sets
(if VAL is FALSE), or just a single solution (when VAL is TRUE).
The default is FALSE.
solve(...,'IgnoreProperties',VAL) controls if solve should take
assumptions on variables into account. VAL can be TRUE or FALSE.
The default is FALSE (i.e., take assumptions into account).
solve(...,'Real',VAL) allows to put the solver into "real mode."
In "real mode," only real solutions such that all intermediate values
of the input expression are real are searched. VAL can be TRUE
or FALSE. The default is FALSE.
solve(...,'MaxDegree',n) controls the maximum degree of polynomials
for which explicit formulas will be used during the computation.
n must be a positive integer smaller than 5. The default is 3.
Examples:
solve('p*sin(x) = r') chooses 'x' as the unknown and returns
ans =
asin(r/p)
pi - asin(r/p)
[x,y] = solve('x^2 + x*y + y = 3','x^2 - 4*x + 3 = 0') returns
x =
1
3
y =
1
-3/2
S = solve('x^2*y^2 - 2*x - 1 = 0','x^2 - y^2 - 1 = 0') returns
the solutions in a structure.
S =
x: [8x1 sym]
y: [8x1 sym]
[u,v] = solve('a*u^2 + v^2 = 0','u - v = 1') regards 'a' as a
parameter and solves the two equations for u and v.
S = solve('a*u^2 + v^2','u - v = 1','a,u') regards 'v' as a
parameter, solves the two equations, and returns S.a and S.u.
[a,u,v] = solve('a*u^2 + v^2','u - v = 1','a^2 - 5*a + 6') solves
the three equations for a, u and v.
S = solve('x^(5/2) = 8^(10/3)') returns all three complex solutions:
S =
16
- 4*5^(1/2) - 4 + 4*2^(1/2)*(5 - 5^(1/2))^(1/2)*i
- 4*5^(1/2) - 4 - 4*2^(1/2)*(5 - 5^(1/2))^(1/2)*i
S = solve('x^(5/2) = 8^(10/3)', 'PrincipalValue', true) selects one of these:
S =
- 4*5^(1/2) - 4 + 4*2^(1/2)*(5 - 5^(1/2))^(1/2)*i
S = solve('x^(5/2) = 8^(10/3)', 'IgnoreAnalyticConstraints', true)
ignores branch cuts during internal simplifications and, in this case,
also returns only one solution:
S =
16
syms t positive
solve(t^2-1)
ans =
1
solve(t^2-1, 'IgnoreProperties', true)
ans =
1
-1
solve(x^3-1) returns all three complex roots:
ans =
1
- 1/2 + (3^(1/2)*i)/2
- 1/2 - (3^(1/2)*i)/2
solve(x^3-1, 'Real', true) only returns the real root:
ans =
1
这是具体的用法,注意变量的选取。。。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询