System of equations and inequalities

1 回表示 (過去 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 Center および File ExchangePower 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