Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

system of linear equations but with condtions that all variables should be > 0

1 vue (au cours des 30 derniers jours)
Julio
Julio le 19 Sep 2013
Clôturé : MATLAB Answer Bot le 20 Août 2021
I have the following system of linear equations
x - 2y - 3z = 5
-5x + y - 4z = 20
-3x -4y + z = 49
I want to solve for x,y, and z but want those to be greater than 0.
Adding conditions for x>=0, y>=0, and z>=0.
It's shown here only as a sample of 3 equations, but I have to deal with 184 equations and 184 variables which need to be greater or equal to 0.
Thanks, Julio Fernandez
  2 commentaires
Walter Roberson
Walter Roberson le 19 Sep 2013
Will you always have N linear equations in N unknowns? And the rank() will be N? If so, then if the straightforward use of the mldivide ('\') operator does not give you non-negative solutions then the equations are not solvable under the additional conditions.
Azzi Abdelmalek
Azzi Abdelmalek le 19 Sep 2013
That's why I've suggested A\b. Maybe he wants to take the solution, only when his conditions are true.

Réponses (2)

Shashank Prasanna
Shashank Prasanna le 19 Sep 2013
If you'd like to add positive constraints then you can use a solver in the Optimization Toolbox called LSQNONNEG. If you'd like to add more generic constraints you can use LSQLIN
There isn't a way to do this from base MATLAB, unless you code it yourself.

Azzi Abdelmalek
Azzi Abdelmalek le 19 Sep 2013
For a system A*x=b the solution is
x=A\b

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by