Solve nonlinear equation with positive solution (fsolve)

60 vues (au cours des 30 derniers jours)
Benjamin Wodey
Benjamin Wodey le 7 Juin 2018
Commenté : Benjamin Wodey le 8 Juin 2018
Hello, I would like to solve 3 non linear equation:
F(1) = 0.44*x(1) + 0.23*x(2) + 0.33*x(3) - 5140;
F(2) = 0.23*x(1) + 0.44*x(2) + 0.33*x(3) - 4970;
F(3) = 4*(0.44 + 0.23)*(x(1)*x(2)/(3*x(2)+x(1))) + 0.33*x(3) - 4380;
Here, x is 3 different young modulus and my problem is, using fsolve give me negative values... Do you know if it's possible to find positive values or should I try another way ?
Thank for yours answers
  2 commentaires
sloppydisk
sloppydisk le 7 Juin 2018
I assume you're setting each of the three expressions to zero?
Benjamin Wodey
Benjamin Wodey le 7 Juin 2018
right!

Connectez-vous pour commenter.

Réponses (2)

sloppydisk
sloppydisk le 7 Juin 2018
You can set an assumption on the equations using assume, in this case there seem to be no solutions for this problem.
x = sym('x', [3 1]);
F(1) = 0.44*x(1) + 0.23*x(2) + 0.33*x(3) - 5140==0;
F(2) = 0.23*x(1) + 0.44*x(2) + 0.33*x(3) - 4970==0;
F(3) = 4*(0.44 + 0.23)*(x(1)*x(2)/(3*x(2)+x(1))) + 0.33*x(3) - 4380==0;
assume(x>=0)
sol1 = solve(F, x)
  1 commentaire
Benjamin Wodey
Benjamin Wodey le 8 Juin 2018
okay, so maybe I have to find other equations to solve my problem
thank you for your answer

Connectez-vous pour commenter.


Star Strider
Star Strider le 7 Juin 2018
I am not certain what the values of ‘x’ should be.
Try these:
fcn = @(x) [0.44*x(1) + 0.23*x(2) + 0.33*x(3) - 5140; 0.23*x(1) + 0.44*x(2) + 0.33*x(3) - 4970; 4*(0.44 + 0.23)*(x(1)*x(2)/(3*x(2)+x(1))) + 0.33*x(3) - 4380];
[xs,fv] = fsolve(@(x) norm(fcn(x)), [1; 1; 1])
[xs,fv] = fmincon(@(x) sum(fcn(x)), [1; 1; 1], [], [], [], [], [0; 0; 0],[1; 1; 1]*Inf)
The first one provides a sort of ‘pseudo-constraint’ using the norm of the output. The second uses fmincon to constrain the parameters, however since it requires that the argument function return a scalar, leaves that as a problem for you to solve. (I arbitrarily chose to sum them here.)

Produits


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by