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;

回答(2 个)

Walter Roberson
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;
]
eqns = 
sol3_partial = solve(eqns(end), x3)
sol3_partial = 
eqns2 = subs(eqns(1:end-1), x3, sol3_partial)
eqns2 = 
sol2_partial = solve(eqns2(1), x2)
sol2_partial = 
eqns3 = subs(eqns2(2:end), x2, sol2_partial)
eqns3 = 
sol1_partial = solve(eqns3(1), x1)
sol1_partial = 
eqns4 = subs(eqns3(2:end), x1, sol1_partial)
eqns4 = 
simplify(eqns4)
ans = 
sol1 = subs(sol1_partial, t, [0;5/2])
sol1 = 
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})
sol2 = 
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)

Rakshith G
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

类别

Help CenterFile Exchange 中查找有关 Mathematics and Optimization 的更多信息

产品


版本

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by