Explicit solution could not be found, using solve()

조회 수: 2 (최근 30일)
Trevor Gates
Trevor Gates 2017년 7월 9일
편집: Walter Roberson 2017년 7월 9일
Hello,
I have a relatively simple problem that I am able to solve by hand (i.e. solution should be a_sol = s/2). However, when I try to solve it using the solve() function, I get the warning that an explicit solution could not be found. Below is the source code. Any advice would be greatly appreciated.
syms a s lambda1 lambda2;
obj = log(a);
cons1 = a;
cons2 = s/2 - a;
Lagrange = obj + lambda1*cons1 + lambda2*cons2;
eq1 = [char(diff(Lagrange, a)), '=0'];
eq3 = [char(diff(Lagrange, lambda1)), '>=0'];
eq4 = [char(diff(Lagrange, lambda2)), '>=0'];
eq3a = [char(diff(Lagrange, lambda1)*lambda1), '=0'];
eq4a = [char(diff(Lagrange, lambda2)*lambda2), '=0'];
eq6a = 'lambda1>=0';
eq6b = 'lambda2>=0';
[a_sol] = solve(eq1, eq3, eq4, eq3a, eq4a, eq6a, eq6b, a);

채택된 답변

Walter Roberson
Walter Roberson 2017년 7월 9일
This appears to be the same bug as https://www.mathworks.com/support/bugreports/677110 except no trig is involved.
Workaround:
Call the MuPAD symbolic engine directly. For example,
>> S = evalin(symengine,'solve([p1-y1,p2-y2,p3-sin(y3)],[y1,y2,y3])')

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with MuPAD에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by