필터 지우기
필터 지우기

How to solve equality and multiple inequality constraints at the same time?

조회 수: 4 (최근 30일)
Yokuna
Yokuna 2021년 6월 26일
답변: Rakshith G 2021년 11월 22일
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