substitute into a set of inequalities

Hello!
Could you please help me with the following problem. Let's say that I have the following equations:
x1+x2<=17
x1+x3<=27
x2+x3<=21
Here we have 3 unknowns. In matrixform: Ax<=b where
A=
1 1 0
1 0 1
0 1 1
b=
17
27
21
Now I get the new information saying that x1+x2+x3=22 (equation). Then I can isolate x3=22-x1-x2. Then I can substitute this into the previous inequalities, which gives me:
x1+x2<=17
-x2<=5
-x1<=-1
which again can be written in the matrixform Ax<=b where
A=
1 1
0 -1
-1 0
and
b=
17
5
-1
This time there are only 2 unknowns, namely x1 and x2. Once I have them, x3 can be calculated by x3=22-x1-x2. This is just one example. I would like to be able to do this for a general problem. In this example, I would like to give matlab the matrices
1 1 0
1 0 1
0 1 1
and
17
27
21
and the information stating that x1+x2+x3=22.
Then I would like to get the folowing matrices as output:
1 1
0 -1
-1 0
and
17
5
-1
Is it possible to do that in Matlab?
Thank you very much for your time and consideration!
Best regards,
Alex

 Accepted Answer

One way. Define
>> T=[1 0;0 1;-1 -1], c=[0;0;22]
T =
1 0
0 1
-1 -1
c =
0
0
22
Note that your new equation allows you write [x1;x2;x3] in terms of [x1;x2] in matrix form
[x1;x2;x3]=T*[x1;x2]+c
substituting into A*x<=b leads to A*(T*x+c)<=b or
>> Anew=A*T, bnew = b-A*c
Anew =
1 1
0 -1
-1 0
bnew =
17
5
-1

More Answers (0)

Community Treasure Hunt

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

Start Hunting!