matlab solve not giving all the solutions

50 ビュー (過去 30 日間)
mukesh bisht
mukesh bisht 2021 年 11 月 6 日
回答済み: Walter Roberson 2021 年 11 月 6 日
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)

回答 (2 件)

KSSV
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)
r1 = 
4.7230742467055073214514048938575
r2 = vpasolve(eqn,5)
r2 = 
5.1110533936277367834520435303963

Walter Roberson
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
eqn = 
Seqn = simplify(lhs(eqn)-rhs(eqn))
Seqn = 
string(Seqn)
ans = "(14417209*exp((89*pi)/50 - (89*x)/50))/15625 + (50648183*exp((89*pi)/100 - (89*x)/100)*sin(x))/156250 + 150366421/6250000"
fplot([Seqn, 0], [4.5 5.5])
sol = solve(Seqn)
Warning: Unable to solve symbolically. Returning a numeric solution using vpasolve.
sol = 
4.7230742467055073214514048938575
sol1 = vpasolve(Seqn, 4.5)
sol1 = 
4.7230742467055073214514048938575
sol2 = vpasolve(Seqn, 5.5)
sol2 = 
5.1110533936277367834520435303963

カテゴリ

Help Center および File ExchangeSymbolic Math Toolbox についてさらに検索

タグ

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by