How to solve systems of inequalities and obtain numerical values ​​of variables to write them in a .txt file?

8 vues (au cours des 30 derniers jours)
I need to solve some systems of inequalities with two unknowns. I've tried solve and now I'm trying feval. The problem is that I cannot access this information as variables, they appear as conditions or parameters. I need the numerical value to be able to write them in a .txt file.
  2 commentaires
Alex Muniz
Alex Muniz le 31 Déc 2022
** how I'm doing:
syms s;
kp = sym('kp','real');
ki = sym('ki','real');
kd = sym('kd','real');
w = sym('w','real');
eqn1 = (subs(V_jw_even,w,0))*i0 > 0
eqn2 = (subs(V_jw_even,w,w_root))*i1 > 0
eqn3 = (subs(V_jw_even,w,inf))*i2 > 0
eqns = [eqn1 eqn2 eqn3]
[KI KD] = feval(symengine,'numeric::solve',eqns,[ki kd],'AllRealRoots')
KI
KD
** Output I'm getting:
0 < -9*ki
0 < 18*ki - 162*kd - 36
0 < (ki - 9*kd + 5)*sym(inf) + (- kd - 1)*sym(inf)
[0 < -9*ki, 0 < 18*ki - 162*kd - 36, 0 < (ki - 9*kd + 5)*sym(inf) + (- kd - 1)*sym(inf)]solve([vpa("0.0") < -vpa("9.0")*ki, vpa("0.0") < vpa("18.0")*ki - vpa("162.0")*kd - vpa("36.0"), vpa("0.0") < vpa("RD_INF")*ki - vpa("RD_INF")*kd + sym(NaN)], [ki, kd], AllRealRoots)
solve([vpa("0.0") < -vpa("9.0")*ki, vpa("0.0") < vpa("18.0")*ki - vpa("162.0")*kd - vpa("36.0"), vpa("0.0") < vpa("RD_INF")*ki - vpa("RD_INF")*kd + sym(NaN)], [ki, kd], AllRealRoots)
KD = 0
John D'Errico
John D'Errico le 31 Déc 2022
That what you are doing is more complicated than what I showed in my answer is irrelevant. You still have not said how you would plan to write down infinitely many solutions. And for a much more complex problem, simply finding the solutions can be far more difficult than the trivial counter-example I posed.

Connectez-vous pour commenter.

Réponses (1)

John D'Errico
John D'Errico le 31 Déc 2022
Modifié(e) : John D'Errico le 31 Déc 2022
A system of inequalities does not have a "numerical" solution. There will generally be infinitely many solutions (though in very rare cases, there might be a unique solution.) As such, what you ask for is not possible. (feval would certainly be meaningless in this respect.)
In the simplest case, what is the numerical solution to even the most trivial inequality, such as X>2? Let me know when you have finished writing down all solutions. I hope you have a large text file to use, since infinitely many solutions tends to take a great deal of space.

Community Treasure Hunt

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

Start Hunting!

Translated by