System of equations and inequalities

3 visualizaciones (últimos 30 días)
Luciano Mazza
Luciano Mazza el 5 de Oct. de 2021
Respondida: Dongyue el 17 de Nov. de 2022
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.

Respuestas (1)

Dongyue
Dongyue el 17 de Nov. de 2022
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

Categorías

Más información sobre Programming en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by