How to solve equality and multiple inequality constraints at the same time?
1 次查看(过去 30 天)
显示 更早的评论
How can I solve the equations and plot x1 vs t.
%Initial conditions
x1=14; x2=14; x3=14;
%Equations
x1 =t*x1+x2+t*x3;
x2 = 2*t*x1+t*x2+x3;
x3 = t*x1+x2+t*x3;
% Inequality constraints
5<x1<20;
5<x2<20;
5<x3<20;
0 个评论
回答(2 个)
Walter Roberson
2021-6-28
编辑:Walter Roberson
2021-6-28
syms x1 x2 x3 t
x10 = 14; x20 = 14; x30 = 14; x0 = [x10,x20,x30];
eqns = [
x1 == t*x1+x2+t*x3
x2 == 2*t*x1+t*x2+x3;
x3 == t*x1+x2+t*x3;
x1 + x2 + x3 == 42;
]
sol3_partial = solve(eqns(end), x3)
eqns2 = subs(eqns(1:end-1), x3, sol3_partial)
sol2_partial = solve(eqns2(1), x2)
eqns3 = subs(eqns2(2:end), x2, sol2_partial)
sol1_partial = solve(eqns3(1), x1)
eqns4 = subs(eqns3(2:end), x1, sol1_partial)
simplify(eqns4)
sol1 = subs(sol1_partial, t, [0;5/2])
We can see from that the 5/2 version does not satisfy the range constraints for x1
sol2 = subs(sol2_partial, {t, x1}, {0, 14})
and using the equality constraint, we quickly deduce that x3 must be 14 as well.
So the only solution is [14, 14, 14] at time 0
(My internal reference for this is T0098941)
0 个评论
Rakshith G
2021-11-22
How can i solve this inequality function:
x1^2 + 2*x2^2 + 3*x3^2 <= 1
x1, x2, x3 >= 0
Need to find all the values of x1, x2 and x3
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Mathematics and Optimization 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!