MATLAB求解联立方程的问题
发布网友
发布时间:2022-05-31 09:42
我来回答
共3个回答
热心网友
时间:2023-10-23 14:52
图解法啊?把以下程序copy到edit中,即
>> edit
%__________________
ezplot('x.^3-x.^2=y.^2-y ',[-1 4 -2 2])
hold on
ezplot('x.^2+y.^2=3*x*y.^2 ',[-1 4 -2 2])
grid on
[X1,Y1]=ginput
[X2,Y2]=ginput
%________________________
运行后(F5键),在图形界面出现十字,把十字的中心对准曲线的交叉点,鼠标左键单击,再按回车键,得到X1和Y1的坐标;接着又出现十字,重复以上步骤,得到X2和Y2的坐标。
如果还要更精确,把坐标精细化。如
%__________________
clf
ezplot('x.^3-x.^2=y.^2-y ',[-1 2 -1.5 1.5])
hold on
ezplot('x.^2+y.^2=3*x*y.^2 ',[-1 2 -1.5 1.5])
grid on
[X1,Y1]=ginput
[X2,Y2]=ginput
%________________________
运行结果:
X1 = 0.40211132437620
Y1 = -0.89051094890511
X2 = 1.59980806142035
Y2 = 0.81751824817518
用solve检验
[x,y]=solve('x^2+y^2=3*x*y^2','x^3-x^2=y^2-y')
结果:
x =
[ 0]
[ -.37976068921827954137026288853649-.38991830919330475345517214422894*i]
[ -.37976068921827954137026288853649+.38991830919330475345517214422894*i]
[ .40049531124597856184878557883088]
[ .71811586266609446330558969000379-.27108283538804636925417115137930*i]
[ .71811586266609446330558969000379+.27108283538804636925417115137930*i]
[ 1.5894610085250582609472274849012]
y =
[ 0]
[ -.18172153613294090689416426430526+.29745978808608951704552138953654*i]
[ -.18172153613294090689416426430526-.29745978808608951704552138953654*i]
[ .89222640093375821455336170232293]
[ .64500317468890679025944232957649-.349161514367826464526007371833e-1*i]
[ .64500317468890679025944232957649+.349161514367826464526007371833e-1*i]
[ -.818789678045689981283917832866]
实根差不多,虚根就不能用绘图的方法求了。
热心网友
时间:2023-10-23 14:52
>> [x, y] = solve('x^2+y^2=3*x*y^2','x^3-x^2=y^2-y')
x =
0
.40049531124597856184878557883088
1.5894610085250582609472274849012
.71811586266609446330558969000379+.27108283538804636925417115137930*i
-.37976068921827954137026288853649+.38991830919330475345517214422894*i
-.37976068921827954137026288853649-.38991830919330475345517214422894*i
.71811586266609446330558969000379-.27108283538804636925417115137930*i
y =
0
.89222640093375821455336170232293
-.818789678045689981283917832866
.64500317468890679025944232957649+.3491615143678264645260073718334e-1*i
-.18172153613294090689416426430526-.29745978808608951704552138953654*i
-.18172153613294090689416426430526+.29745978808608951704552138953654*i
.64500317468890679025944232957649-.3491615143678264645260073718334e-1*i
>> help solve
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 FINDSYM.
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.
Examples:
solve('p*sin(x) = r') chooses 'x' as the unknown and returns
ans =
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.
See also dsolve.
Overloaded functions or methods (ones with the same name in other directories)
help sym/solve.m
Reference page in Help browser
doc solve
热心网友
时间:2023-10-23 14:53
eq1='
d+(n+p)/2=q';
eq2='
p=n+d+q-10';
eq3='
q+d=p+n/4';
eq4='
q+p=n+8*d-1';
s=solve(eq1,eq2,eq3,eq4,'p,n,d,q')
s.d
s.n
s.p
s.q