Solve nonlinear equation with positive solution (fsolve)

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

sloppydisk
sloppydisk 2018-6-7
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)

Star Strider
Star Strider 2018-6-7
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.)

类别

Help CenterFile Exchange 中查找有关 Solver Outputs and Iterative Display 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by