Find positive solutions to underdetermined linear system of equations
1 回表示 (過去 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
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
2013 年 5 月 3 日
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 件のコメント
参考
カテゴリ
Help Center および File 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!