Explicit solution could not be found, using solve()

2 次查看(过去 30 天)
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