System of equations and inequalities
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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.
0 Kommentare
Antworten (1)
Dongyue
am 17 Nov. 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)
Best,
Dongyue
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!