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

조회 수: 8 (최근 30일)
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
Alex Muniz
Alex Muniz 2022년 12월 31일
** 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 2022년 12월 31일
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.

댓글을 달려면 로그인하십시오.

답변 (1개)

John D'Errico
John D'Errico 2022년 12월 31일
편집: John D'Errico 2022년 12월 31일
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.

카테고리

Help CenterFile Exchange에서 Equation Solving에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by