Explicit solution could not be found, using solve()
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Trevor Gates
le 9 Juil 2017
Modifié(e) : Walter Roberson
le 9 Juil 2017
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);
0 commentaires
Réponse acceptée
Walter Roberson
le 9 Juil 2017
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])')
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Get Started with MuPAD dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!