Find positive solutions to underdetermined linear system of equations
조회 수: 8 (최근 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!