필터 지우기
필터 지우기

System of equations and inequalities

조회 수: 2 (최근 30일)
Luciano Mazza
Luciano Mazza 2021년 10월 5일
답변: Dongyue 2022년 11월 17일
Hi, I am trying to solve a system of equations and inequalities where I have 6 variables and 8 equations, like this:
syms h1 h2 h3 j12 j13 j23
eq1 = + j12 + j23 + j13 - h1 - h2 - h3 == 3;
eq2 = - j12 - j23 + j13 - h1 + h2 - h3 == 3;
eq3 = - j12 + j23 - j13 + h1 - h2 - h3 == 3;
eq4 = + j12 + j23 + j13 + h1 + h2 + h3 == 3;
eq5 = - j12 + j23 - j13 - h1 + h2 + h3 <= 0;
eq6 = - j12 - j23 + j13 + h1 - h2 + h3 <= 0;
eq7 = + j12 - j23 - j13 - h1 - h2 + h3 <= 0;
eq8 = + j12 - j23 - j13 + h1 + h2 - h3 <= 0;
I tried many methods, but none of them seems to work, do you have any suggestions?
PS: A solution of the system is the following, but I expect to find many more.
j12 = - 1; j23 = 2; j13 = 2;
h1 = 1; h2 = 1; h3 = -2.
Thank you in advance.

답변 (1개)

Dongyue
Dongyue 2022년 11월 17일
Hi Luciano,
Please try the following codes, where k and l are variables. For your example, k=2 and l=2:
clear; clc;
syms h1 h2 h3 j12 j13 j23 integer
eq1 = + j12 + j23 + j13 - h1 - h2 - h3 == 3;
eq2 = - j12 - j23 + j13 - h1 + h2 - h3 == 3;
eq3 = - j12 + j23 - j13 + h1 - h2 - h3 == 3;
eq4 = + j12 + j23 + j13 + h1 + h2 + h3 == 3;
eq5 = - j12 + j23 - j13 - h1 + h2 + h3 <= 0;
eq6 = - j12 - j23 + j13 + h1 - h2 + h3 <= 0;
eq7 = + j12 - j23 - j13 - h1 - h2 + h3 <= 0;
eq8 = + j12 - j23 - j13 + h1 + h2 - h3 <= 0;
eqs = [eq1,eq2,eq3,eq4,eq5,eq6,eq7,eq8];
vars = [h1, h2, h3, j12, j13, j23];
S = solve(eqs, vars,'Real',true,'ReturnConditions',true)
S = struct with fields:
h1: 3 - l h2: 3 - k h3: k + l - 6 j12: 3 - l - k j13: k j23: l parameters: [k l] conditions: in(k, 'integer') & in(l, 'integer') & h2 + j12 + 3 <= h3 + j13 + j23 + l & h3 + j13 + 3 <= h2 + j12 + j23 + l & h3 + j12 + l <= h2 + j13 + j23 + 3 & h2 + h3 + j23 + l <= j12 + j13 + 3
Best,
Dongyue

카테고리

Help CenterFile Exchange에서 Power and Energy Systems에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by