Find positive solutions to underdetermined linear system of equations

7 次查看(过去 30 天)
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 个评论
Matt Kindig
Matt Kindig 2013-5-3
编辑:Matt Kindig 2013-5-3
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?

请先登录,再进行评论。

回答(1 个)

Shashank Prasanna
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

类别

Help CenterFile Exchange 中查找有关 Get Started with Optimization Toolbox 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by