Solving a set of equations and inequalities

15 次查看(过去 30 天)
Hi, I am working on a problem to solve a set of 2 equations and 2 inequalities I got from applying Hurqitz stability criteria for a controller design algorithm.
I got the system using solve() but how to get a particular solution from the output of this solve() function. Conditions parameter shows some function.
syms Kpx Kix % PI controller
% The maxima/minima of this equation is to be solved for Kix and Kpx. Every
% other variable is some constant numerical value.
T = 0.4652;
c3 = T; c2 = 1+1.6*T; c1 = 1.6+4*T; c0 = 4;
d4 = T; d3 = 1+1.6*T; d2 = 1.6+4*T;
ISE4 = (c3*c3*(16*Kix*(4+16*Kpx)*d2 - 16*Kix*16*Kix*d3) + 16*Kix*(4+16*Kpx)*d4*(c2*c2 +2*c1*c3) + 16*Kix*d3*d4*(c1*c1 - 2*c0*c2) + c0*c0*(d2*d3*d4 - (4+16*Kpx)*d4*d4))/(2*16*Kix*d4*((4+16*Kpx)*d2*d3 - 16*Kix*d3*d3- (4+16*Kpx)*(4+16*Kpx)*d4));
ISEKp = diff(ISE4, Kpx) == 0;
ISEKi = diff(ISE4, Kix) == 0; % Max/Min conditions
ISEKp1 = Kpx < 0.0652;
ISEKp2 = Kpx > -0.0291; % Stability conditions from Hurwitz Criteria
ISEKi1 = Kix > 0;
% eqns = [ISEKp ISEKi];
% [x1, x2] = vpasolve(eqns, [Kpx, Kix]) % Doesn't take inequalities
% into account
% Kp = double(x1(8,1))
% Ki = double(x2(8,1))
eqns = [ISEKp ISEKi ISEKp1 ISEKp2 ISEKi1];
X = solve(eqns, [Kpx, Kix], Real=true, ReturnConditions=true) % How to get one solution out of the infinite solutions provided?
X = struct with fields:
Kpx: (34507100878762346168055722004523112768983738441438576824569961297545565933326311549769537483995417236328125*y^4)/847020229739709285495136549570717729313154390014956487612558202927983338057597417707783758809965409599488 - (632648203064… Kix: y parameters: y conditions: (34507100878762346168055722004523112768983738441438576824569961297545565933326311549769537483995417236328125*y^4)/847020229739709285495136549570717729313154390014956487612558202927983338057597417707783758809965409599488 - (632648203064…
  2 个评论
John D'Errico
John D'Errico 2022-2-1
Since you don't show the value of those other incidental variables, we cannot actually show you how to solve your problem, since we cannot run that code. If you want help, is there a good reason why you would make it more difficult to get help?
Karan Juneja
Karan Juneja 2022-2-1
Updated the code with variables. I also tried using the sub() function to get one of the values. But is there any other way, suppose if I don't know this range of values?
eqns = [ISEKp ISEKi ISEKp1 ISEKi1];
X = solve(eqns, [Kpx, Kix], ReturnConditions=true,IgnoreAnalyticConstraints=true)
estimate = 0.14; % 0.3257 > estimate or the y parameter> 0
Kp = double(subs(X.Kpx, X.parameters, estimate))
Ki = double(subs(X.Kix, X.parameters, estimate))

请先登录,再进行评论。

采纳的回答

Walter Roberson
Walter Roberson 2022-2-2
编辑:Walter Roberson 2022-2-2
syms Kpx Kix % PI controller
% The maxima/minima of this equation is to be solved for Kix and Kpx. Every
% other variable is some constant numerical value.
T = 0.4652;
c3 = T; c2 = 1+1.6*T; c1 = 1.6+4*T; c0 = 4;
d4 = T; d3 = 1+1.6*T; d2 = 1.6+4*T;
ISE4 = (c3*c3*(16*Kix*(4+16*Kpx)*d2 - 16*Kix*16*Kix*d3) + 16*Kix*(4+16*Kpx)*d4*(c2*c2 +2*c1*c3) + 16*Kix*d3*d4*(c1*c1 - 2*c0*c2) + c0*c0*(d2*d3*d4 - (4+16*Kpx)*d4*d4))/(2*16*Kix*d4*((4+16*Kpx)*d2*d3 - 16*Kix*d3*d3- (4+16*Kpx)*(4+16*Kpx)*d4));
ISEKp = diff(ISE4, Kpx) == 0;
ISEKi = diff(ISE4, Kix) == 0; % Max/Min conditions
ISEKp1 = Kpx < 0.0652;
ISEKp2 = Kpx > -0.0291; % Stability conditions from Hurwitz Criteria
ISEKi1 = Kix > 0;
% eqns = [ISEKp ISEKi];
% [x1, x2] = vpasolve(eqns, [Kpx, Kix]) % Doesn't take inequalities
% into account
% Kp = double(x1(8,1))
% Ki = double(x2(8,1))
eqns = [ISEKp ISEKi ISEKp1 ISEKp2 ISEKi1];
X = solve(eqns, [Kpx, Kix], Real=true, ReturnConditions=true) % How to get one solution out of the infinite solutions provided?
X = struct with fields:
Kpx: (34507100878762346168055722004523112768983738441438576824569961297545565933326311549769537483995417236328125*y^4)/847020229739709285495136549570717729313154390014956487612558202927983338057597417707783758809965409599488 - (632648203064… Kix: y parameters: y conditions: (34507100878762346168055722004523112768983738441438576824569961297545565933326311549769537483995417236328125*y^4)/847020229739709285495136549570717729313154390014956487612558202927983338057597417707783758809965409599488 - (632648203064…
string(X.conditions)
ans = "(34507100878762346168055722004523112768983738441438576824569961297545565933326311549769537483995417236328125*y^4)/847020229739709285495136549570717729313154390014956487612558202927983338057597417707783758809965409599488 - (10389353489109644537606890544364750875985455986886901586713561389388177805876854668864414635540498558473069375*y^2)/1970169054374563798061687614301489438382397111174788790186810380010489244321971593588305022991979542728409088 - (6326482030647950373666319861024196355951189918432847939302047140666280082419174977438516391877212365740703125*y^3)/246271131796820474757710951787686179797799638896848598773351297501311155540246449198538127873997442841051136 - (7021441003762571396906849433834420747241464620819343818217715727218707127347568050182545324879631345784830457*y)/2462711317968204747577109517876861797977996388968485987733512975013111555402464491985381278739974428410511360 + 10284141242117406867047512558911453927056095857606903324727496881661357853999416489223054215882483933385581789437/18330452881900941577165941563461057734709822722370234903898083775617591929171623706745589933917377665545118154752 < 163/2500 & -291/10000 < (34507100878762346168055722004523112768983738441438576824569961297545565933326311549769537483995417236328125*y^4)/847020229739709285495136549570717729313154390014956487612558202927983338057597417707783758809965409599488 - (10389353489109644537606890544364750875985455986886901586713561389388177805876854668864414635540498558473069375*y^2)/1970169054374563798061687614301489438382397111174788790186810380010489244321971593588305022991979542728409088 - (6326482030647950373666319861024196355951189918432847939302047140666280082419174977438516391877212365740703125*y^3)/246271131796820474757710951787686179797799638896848598773351297501311155540246449198538127873997442841051136 - (7021441003762571396906849433834420747241464620819343818217715727218707127347568050182545324879631345784830457*y)/2462711317968204747577109517876861797977996388968485987733512975013111555402464491985381278739974428410511360 + 10284141242117406867047512558911453927056095857606903324727496881661357853999416489223054215882483933385581789437/18330452881900941577165941563461057734709822722370234903898083775617591929171623706745589933917377665545118154752 & in(y, 'real') & ((3889503364931186315391311562659059508626681930031214187670213233126249714491660752761911232771190967583089971212270400624581571569702044034459084075166513979600687301250146245157387840131537567220636590540952896806265858177988621129955301964230965809*y^2)/10801051397654735969264549761302125540561601513627366742741379932079593203588349979242883592937891313148958732464706151510220746855850232276012834951836641290514412752415558932731142955800972035853762192737733407268186943156079191064434241422611718750 - (40374588249136566629452043465917046096693299415622760437651333125174747950876974148927199606229372572938962941603651774662664618273420812127531323113171608856783722752011896361614510136417731526565402132713811449086080560646724295597725999971523621348546*y)/799952869138803882723655716696438672847843612103026849384283451219644871640762170337676066101962575380094756123167299346225724064011407827942200588620401245578723694475777333455400275164009491405419262399638380475800095477497115088209661005362180419921875 + (13150653199530933189484524389349142473467552929514154883531545163846059670586739946261626072030177516552106834694383252299780139526502248858205831666470855843455032945287444842955186598163655479569531932184428714042311959345976459061417892741773572*y^3)/25922523354371366326234919427125101297347843632705680182579311836991023688612039950182920623050939151557500957915294763624529792454040557462430803884407939097234590605797341438554743093922332886049029262570560177443648663574590058554642179414268125 + y^4 - 287893850481767298624591884489216940217282924012780149574946467096235012614695794458376187274070651746465613137101963135993994678276981942724725334452782600843036073034250608749633053082777984077588606494219123267171994916373376489283/846820863370516630739728246117679264674285450468302143336831798630124189667060762489939981540995959618719472181469702043566550663573292194835823988795643811710799104387143942880033468885440774603209479664780571528174260715819594954604394495304786674000 ~= 0 | ~in(y, 'real')) & (~in(y, 'real') | (15142728523037363746562322002735716030893478256243417298161138309584463514890043086974776842822151749990209251242522416665164633636584594833819773074093439931522874569873698832478848645757669727583659602957198730990847306432894916848343435139273358078*y)/5605071627170301100051944167490236039485865317581495208418297302253174528753723620397556662440276366287802808167049952765530991601816632527544191119731097588901435249155950569676513602968190586482797316444287295618941282909541119468445431624703857421875 + (327557257666691326329465463890405490336879713668331367576218061900464203625275827061870502380060864541507206756679282255967637778516741701204111001915260309185298790492605994838067616163828416771739326039465980792656030516061082738474720579308704109*y^2)/7038267157155618596520922296392802722999972651950434489558165726373606496865435229663767353342726778933544792027485510308109802112660885401675743785788922542012941477421142993821647460942335521254348022674345566144290826134512393054047934394564843750 - (1893640918251017669529939040165146379405804629767878720188130637013793117061350996606375687234228473865902256459468931781330504668383919442574792304081797738220795361434397110658993952053537651336709571291158193553131502392793751803938916163516676*y^3)/5630613725724494877216737837114242178399978121560347591646532581098885197492348183731013882674181423146835833621988408246487841690128708321340595028631138033610353181936914395057317968753868417003478418139476452915432660907609914443238347515651875 + y^4 + 88344240755794687488130686244059155195337972938087348103912678812203952104502023914418832076425398733358119369473697266634159096489313083401327453431339582184128679094916981592115381877897520864295555950780289127614297963706288111/4854652408477554635392771587195732350731775154248446270289346383142496425008839639429014545440054114857119867548972940616657486742183745073921969261659055194031844403958408294425160849409493663803200812888217506763741528081721769940658389721483142000 ~= 0) & (9764844811149744146231378070411615825616264898283630210390215950113091*y)/711173444357079636422148574084292087998259955415451459702917480468750000 - (180587177869066749160684963053363732945126292655783179687840411818*y^2)/1895647186162465066989390008307227405670340379869217132484130859375 - (7023765822910589304615706812702159470193242209300667674394833*y^3)/76785708806580863472987949703583894913228977412423985113281250 - (37370682699467734941240597020444241635402368926180066224428*y^4)/61428567045264690778390359762867115930583181929939188090625 + y^5 + 1556155627217174522033715191849435529216/16825426443624353630394275168732498538665545767568565234375 == 0 & 0 < y"
C = X.conditions;
Y = X.parameters;
assume(~in(Y, 'real'))
C1 = simplify(C)
C1 = 
symfalse
assume(Y < 0)
C2 = simplify(C)
C2 = 
symfalse
assume(Y > 0)
C3 = simplify(C)
C3 = 
assume(Y, 'clear')
string(C3)
ans = "302710189145642068533172720182760090594104211846792536522096694453505821*y + 22046376775069468729086605796613054727946058617878995250790441894531250000*y^5 + 2039032614907334447152225744470705440431276032000000000 == 5815000*y^2*(346798437506210346915400523877169123840791334084220466423244879375*y + 2306471822857774265904693097355543038434989957162675962288915625000*y^2 + 361174355738133498321369926106727465890252585311566359375680823636) & 0 < 466732349284867077941809598559358221148315661199981344170317679822599085688732358865602335451901974959230957031250000*y^4 - 60414090539172582986184068515481026343855426563747332726739359479292253941173909899446571105667999117520898415625000*y^2 - 294307944065742651382957199934845614478849355005496086136331232983795349434140019950439782550127919254257509375000000*y^3 - 32663743549503482138410663566197725316167293416051587442348813563021425556420886569449200851340045020591031285964000*y + 6760973388112952666839400911505106691960094811767423225269331949707393611961444211930844301849674764658090454837677 & 466732349284867077941809598559358221148315661199981344170317679822599085688732358865602335451901974959230957031250000*y^4 - 60414090539172582986184068515481026343855426563747332726739359479292253941173909899446571105667999117520898415625000*y^2 - 294307944065742651382957199934845614478849355005496086136331232983795349434140019950439782550127919254257509375000000*y^3 - 32663743549503482138410663566197725316167293416051587442348813563021425556420886569449200851340045020591031285964000*y + 5680622321385915922635183230608620601720634635067727505620838637181931787635891639714526095119419318495025053591981 < 0 & 751290338139933231840843624813784393767268915525908326223816006793251709869918734963237330272716164837248222417360752222922863216831814472069102860489897297607031512969437367496922804618461148246329002885538603444593787072514245692482485407470111546053743968*y + 5060634090499815796135404219537016527256926398662151066747105866926006081117699511963643916927023175230840855925620445749894437704087573211958062519677819155443993471305186481927143511220706751363862223531195526180757723139375758600677734375 ~= 459385000*y^2*(16438316499413666486855655486686428091834441161892693604414431454807574588233424932827032590037721895690133543367979065374725174408127811072757289583088569804318791181609306053693983247704569349461914915230535892552889949182470573826772365927216965000*y + 32403154192964207907793649283906376621684804540882100228224139796238779610765049937728650778813673939446876197394118454530662240567550696828038504855509923871543238257246676798193428867402916107561286578213200221804560829468237573193302724267835156250*y^2 + 11668510094793558946173934687977178525880045790093642563010639699378749143474982258285733698313572902749269913636811201873744714709106132103377252225499541938802061903750438735472163520394612701661909771622858690418797574533965863389865905892692897427)"
C3c = children(C3).'
C3c = 4×1 cell array
{[22046376775069468729086605796613054727946058617878995250790441894531250000*y^5 + 302710189145642068533172720182760090594104211846792536522096694453505821*y + 2039032614907334447152225744470705440431276032000000000 == 5815000*y^2*(2306471822857774265904693097355543038434989957162675962288915625000*y^2 + 346798437506210346915400523877169123840791334084220466423244879375*y + 361174355738133498321369926106727465890252585311566359375680823636) ]} {[0 < 466732349284867077941809598559358221148315661199981344170317679822599085688732358865602335451901974959230957031250000*y^4 - 294307944065742651382957199934845614478849355005496086136331232983795349434140019950439782550127919254257509375000000*y^3 - 60414090539172582986184068515481026343855426563747332726739359479292253941173909899446571105667999117520898415625000*y^2 - 32663743549503482138410663566197725316167293416051587442348813563021425556420886569449200851340045020591031285964000*y + 6760973388112952666839400911505106691960094811767423225269331949707393611961444211930844301849674764658090454837677 ]} {[466732349284867077941809598559358221148315661199981344170317679822599085688732358865602335451901974959230957031250000*y^4 - 294307944065742651382957199934845614478849355005496086136331232983795349434140019950439782550127919254257509375000000*y^3 - 60414090539172582986184068515481026343855426563747332726739359479292253941173909899446571105667999117520898415625000*y^2 - 32663743549503482138410663566197725316167293416051587442348813563021425556420886569449200851340045020591031285964000*y + 5680622321385915922635183230608620601720634635067727505620838637181931787635891639714526095119419318495025053591981 < 0 ]} {[751290338139933231840843624813784393767268915525908326223816006793251709869918734963237330272716164837248222417360752222922863216831814472069102860489897297607031512969437367496922804618461148246329002885538603444593787072514245692482485407470111546053743968*y + 5060634090499815796135404219537016527256926398662151066747105866926006081117699511963643916927023175230840855925620445749894437704087573211958062519677819155443993471305186481927143511220706751363862223531195526180757723139375758600677734375 ~= 459385000*y^2*(32403154192964207907793649283906376621684804540882100228224139796238779610765049937728650778813673939446876197394118454530662240567550696828038504855509923871543238257246676798193428867402916107561286578213200221804560829468237573193302724267835156250*y^2 + 16438316499413666486855655486686428091834441161892693604414431454807574588233424932827032590037721895690133543367979065374725174408127811072757289583088569804318791181609306053693983247704569349461914915230535892552889949182470573826772365927216965000*y + 11668510094793558946173934687977178525880045790093642563010639699378749143474982258285733698313572902749269913636811201873744714709106132103377252225499541938802061903750438735472163520394612701661909771622858690418797574533965863389865905892692897427)]}
C31 = C3c{1} %equality
C31 = 
C32 = C3c{2} %<
C32 = 
C33 = C3c{3} %<
C33 = 
C34 = C3c{4} %~=
C34 = 
C31sol = solve(C31)
C31sol = 
cross_check = simplify(subs([C32, C33, C34], Y, C31sol))
cross_check = 
Now... for there to be a solution, an entire row of cross_check must be symtrue, in which case the corresponding row of C31sol would be the y value (and so the Kix value). But there are no y values to the polynomial equality C31 that also satisfy all the other conditions.
And what that means is that it turns out that your system has no solutions.

更多回答(1 个)

KSSV
KSSV 2022-2-2
X is a structure. You can access the fields using:
Kpx = X.Spx ;
Kix = X.Kix ;
Also read about double and vpasolve.
  1 个评论
Karan Juneja
Karan Juneja 2022-2-2
编辑:Karan Juneja 2022-2-2
Yes, that I can access but it shows as a sym with X.parameters as y. Kpx and Kix have a term y in them. I need to find the range of y which I can later substitute using the sub() function.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Equation Solving 的更多信息

产品


版本

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by