How to use equation solver with conditions
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Alex Karakostas
le 16 Jan 2019
Réponse apportée : Star Strider
le 16 Jan 2019
syms x a r
x = isolate(-((2*(90 - x)^r - (2*x + 90)^r)*(a + 4)*(r - 1)==0,a)
Is it possible to ask matlab to solve the above equation setting as a condition that "a" is a positive number?
Ideally, I want matlab to return an equation rather than -4 as the solution.
0 commentaires
Réponse acceptée
Star Strider
le 16 Jan 2019
Theoretically, yes:
syms x a r
assume(a > 0)
x = isolate(-((2*(90 - x)^r - (2*x + 90)^r)*(a + 4)*(r - 1))==0,a)
However,
Error using sym/isolate (line 108)
Unable to isolate 'a' because the equation has no solution.
Note that the equation you posted has an unmatched parenthesis. I added one to get this to work, so be sure all of them are in the correct places, and that you are not using more of them than you need to.
0 commentaires
Plus de réponses (1)
Walter Roberson
le 16 Jan 2019
No. Your equation has three terms multiplied together
-2*(90 - x)^r + (2*x + 90)^r
a + 4
r - 1
in order for the result to equal zero, one of the terms must equal 0. The only term that involves a is a+4 . In order for that to equal 0, a must be -4.
There are two solutions in r: r = 1 or r = -ln(2)/(ln(90 - x) - ln(2*x + 90)) neither of which involve a and so under the positivity constraint would be valid for all positive a other than x = 0 (as 0 gives a division by 0)
0 commentaires
Voir également
Catégories
En savoir plus sur Symbolic Math Toolbox 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!