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?
2 个评论
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?
采纳的回答
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?
string(X.conditions)
C = X.conditions;
Y = X.parameters;
assume(~in(Y, 'real'))
C1 = simplify(C)
assume(Y < 0)
C2 = simplify(C)
assume(Y > 0)
C3 = simplify(C)
assume(Y, 'clear')
string(C3)
C3c = children(C3).'
C31 = C3c{1} %equality
C32 = C3c{2} %<
C33 = C3c{3} %<
C34 = C3c{4} %~=
C31sol = solve(C31)
cross_check = simplify(subs([C32, C33, C34], Y, C31sol))
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.
0 个评论
更多回答(1 个)
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Equation Solving 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!