matlab solve not giving all the solutions
54 次查看(过去 30 天)
显示 更早的评论
Hi I have the following equation which has two solutions but the matalb "solve" giving only one solution. How can I get all the solutions for a equation?
syms x
eqn = (30.3760*exp(0.89*(pi-x))*cos(x))^2 + (2*2.6678 + 30.3760*exp(0.89*(pi-x))*sin(x))^2 == 2.1^2;
x = double(solve(eqn))
x = 4.7231;
But it has two solution (4.7231, 5.1110)
0 个评论
回答(2 个)
KSSV
2021-11-6
Use vpasolve and specify the Intervel or initial condition. Read about vpasolve.
syms x
eqn = (30.3760*exp(0.89*(pi-x))*cos(x))^2 + (2*2.6678 + 30.3760*exp(0.89*(pi-x))*sin(x))^2 == 2.1^2;
r1 = vpasolve(eqn,4)
r2 = vpasolve(eqn,5)
0 个评论
Walter Roberson
2021-11-6
The symbolic toolbox is not able to solve that to a closed form solution. It is a non-linear equation, and the symbolic toolbox is only able to find multiple solutions to polynomials (and certain cases where the non-linear equations happen to factor.)
format long g
syms x
Q = @(v) sym(v);
eqn = (Q(30.3760)*exp(Q(0.89)*(Q(pi)-x))*cos(x))^2 + (Q(2)*Q(2.6678) + Q(30.3760)*exp(Q(0.89)*(Q(pi)-x))*sin(x))^2 == Q(2.1)^2
Seqn = simplify(lhs(eqn)-rhs(eqn))
string(Seqn)
fplot([Seqn, 0], [4.5 5.5])
sol = solve(Seqn)
sol1 = vpasolve(Seqn, 4.5)
sol2 = vpasolve(Seqn, 5.5)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!