Find positive solutions to underdetermined linear system of equations
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
I'm a bit new to matlab so sorry if this is too simple, in particular i'm new to this forum so I apologise if I did something wrong.
Consider a problem of the following type:
Find x_1,x_2,x_3 > 0 such that
67.5=60*x_1+90*x_2+120*x_3 and
60=30*x_1+120*x_2+90*x_3
In this case I want the solution 0<x_3<3/7, x_2=7/20 - 4/10*x_3 and x_1=2/5-7/5*x_3
Is there a easy way to make Matlab solve such a problem for me?
2 Commenti
Matt Kindig
il 3 Mag 2013
Modificato: Matt Kindig
il 3 Mag 2013
Yes, there are a few ways to do what you want. First important question: do you have the Optimization Toolbox? If you type
ver
at the prompt, do you see "Optimization Toolbox" in the listed toolbox?
Risposte (1)
Shashank Prasanna
il 3 Mag 2013
Henrik, Solving linear systems is easy in MATLAB:
C = [60 90 120;30 120 90];
d = [67.5; 60];
x = C\d;
But as you noticed there aren't any constraints here. If you want to put in your constraints, you will have to setup your own optimization problem - which is easy enough as well. As Matt mentioned if you have the Optimization Toolbox, this will be a much easier exercise.
Here is an example of doing that using an Optimization Toolbox function:
lb = [0;0;0];
ub = [Inf;Inf;3/7]; % lower and upper bounds
Aeq = [0 1 4/10;1 0 7/5];
beq = [7/20;2/5];
x = lsqlin(C,d,[],[],Aeq,beq,lb,ub)
If you want to know what those inputs are you will find that exact information in the link below: http://www.mathworks.com/help/optim/ug/lsqlin.html
0 Commenti
Vedere anche
Categorie
Scopri di più su Get Started with Optimization Toolbox in Help Center e File Exchange
Prodotti
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!