Hello i need help with this error i am working in LQR control by LMI
A1 = [0 0;0 0];%A1
A2 = [0 10*c/a;-5*c/a 0];%A2
A3 = [0 0;0 -10*c/a];%A3
A4 = [0 10*c/a;-5*c/a -10*c/a];%A4
B = [1/(a*Ra) 1/(a*Ra);L/(a*Ra) -L/(a*Ra)];%Bi
alpha = 3;
beta = 0.1;
% تعريف مصفوفات التكلفة
Q = [6 0; 0 9];
R = 1;
% حل معادلة P B R^-1 B^T P = Q يدويًا
%[P, ~, ~] = care(A, B, Q, R);
%[K,p,e] = lqr(A,B,Q,R)
%disp(‘Matrix P calculated using manual method:’);
%disp(P)
%disp(‘Matrix K calculated using manual method:’);
%disp (K)
%% CONTROLLER: LQR via H2 control
P = sdpvar(2,2);
Y = sdpvar(2,2);
E= 1e-6
W001 = sdpvar(2,2);
W002 = sdpvar(2,2);
W003 = sdpvar(2,2);
W004 = sdpvar(2,2);
gamma = 1;
H11 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(alpha)*P;
H12 = [-Y (R^0.5)*W001; ((R^0.5)*W001)’ -P];
H13 = trace((Q^0.5)*P*(Q^0.5)’) + trace(Y);
H14 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(beta)*P;
H21 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(alpha)*P;
H22 = [-Y (R^0.5)*W002; ((R^0.5)*W002)’ -P];
H23 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(beta)*P;
H31 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(alpha)*P;
H32 = [-Y (R^0.5)*W003; ((R^0.5)*W003)’ -P];
H33 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(beta)*P;
H41 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(alpha)*P;
H42 = [-Y (R^0.5)*W004; ((R^0.5)*W004)’ -P];
H43 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(beta)*P;
F = [P>=0]+[-H11<=0]+[H12<=0]+[H13<=gamma]+[H14<=0]+[-H21<=0]+[H22<=0]+[H23<=0]+[-H31<=0]+…
[H32<=0]+[H33<=0]+[-H41<=0]+[H42<=0]+[H43<=0]…
;
ops = sdpsettings(‘solver’,’sedumi’);
% ops = sdpsettings(‘solver’,’gurobi’);
[opt_info] = optimize(F,[],ops);
Pfeasible = value (P);
P_eigs = eig(Pfeasible);
result :
Error using eig
Input matrix contains NaN or Inf.
Error in DYNAMIC2 (line 69)
P_eigs = eig(Pfeasible);A1 = [0 0;0 0];%A1
A2 = [0 10*c/a;-5*c/a 0];%A2
A3 = [0 0;0 -10*c/a];%A3
A4 = [0 10*c/a;-5*c/a -10*c/a];%A4
B = [1/(a*Ra) 1/(a*Ra);L/(a*Ra) -L/(a*Ra)];%Bi
alpha = 3;
beta = 0.1;
% تعريف مصفوفات التكلفة
Q = [6 0; 0 9];
R = 1;
% حل معادلة P B R^-1 B^T P = Q يدويًا
%[P, ~, ~] = care(A, B, Q, R);
%[K,p,e] = lqr(A,B,Q,R)
%disp(‘Matrix P calculated using manual method:’);
%disp(P)
%disp(‘Matrix K calculated using manual method:’);
%disp (K)
%% CONTROLLER: LQR via H2 control
P = sdpvar(2,2);
Y = sdpvar(2,2);
E= 1e-6
W001 = sdpvar(2,2);
W002 = sdpvar(2,2);
W003 = sdpvar(2,2);
W004 = sdpvar(2,2);
gamma = 1;
H11 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(alpha)*P;
H12 = [-Y (R^0.5)*W001; ((R^0.5)*W001)’ -P];
H13 = trace((Q^0.5)*P*(Q^0.5)’) + trace(Y);
H14 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(beta)*P;
H21 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(alpha)*P;
H22 = [-Y (R^0.5)*W002; ((R^0.5)*W002)’ -P];
H23 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(beta)*P;
H31 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(alpha)*P;
H32 = [-Y (R^0.5)*W003; ((R^0.5)*W003)’ -P];
H33 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(beta)*P;
H41 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(alpha)*P;
H42 = [-Y (R^0.5)*W004; ((R^0.5)*W004)’ -P];
H43 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(beta)*P;
F = [P>=0]+[-H11<=0]+[H12<=0]+[H13<=gamma]+[H14<=0]+[-H21<=0]+[H22<=0]+[H23<=0]+[-H31<=0]+…
[H32<=0]+[H33<=0]+[-H41<=0]+[H42<=0]+[H43<=0]…
;
ops = sdpsettings(‘solver’,’sedumi’);
% ops = sdpsettings(‘solver’,’gurobi’);
[opt_info] = optimize(F,[],ops);
Pfeasible = value (P);
P_eigs = eig(Pfeasible);
result :
Error using eig
Input matrix contains NaN or Inf.
Error in DYNAMIC2 (line 69)
P_eigs = eig(Pfeasible); A1 = [0 0;0 0];%A1
A2 = [0 10*c/a;-5*c/a 0];%A2
A3 = [0 0;0 -10*c/a];%A3
A4 = [0 10*c/a;-5*c/a -10*c/a];%A4
B = [1/(a*Ra) 1/(a*Ra);L/(a*Ra) -L/(a*Ra)];%Bi
alpha = 3;
beta = 0.1;
% تعريف مصفوفات التكلفة
Q = [6 0; 0 9];
R = 1;
% حل معادلة P B R^-1 B^T P = Q يدويًا
%[P, ~, ~] = care(A, B, Q, R);
%[K,p,e] = lqr(A,B,Q,R)
%disp(‘Matrix P calculated using manual method:’);
%disp(P)
%disp(‘Matrix K calculated using manual method:’);
%disp (K)
%% CONTROLLER: LQR via H2 control
P = sdpvar(2,2);
Y = sdpvar(2,2);
E= 1e-6
W001 = sdpvar(2,2);
W002 = sdpvar(2,2);
W003 = sdpvar(2,2);
W004 = sdpvar(2,2);
gamma = 1;
H11 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(alpha)*P;
H12 = [-Y (R^0.5)*W001; ((R^0.5)*W001)’ -P];
H13 = trace((Q^0.5)*P*(Q^0.5)’) + trace(Y);
H14 = A1*P + B*W001 + (A1*P + B*W001)’ + 2*(beta)*P;
H21 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(alpha)*P;
H22 = [-Y (R^0.5)*W002; ((R^0.5)*W002)’ -P];
H23 = A2*P + B*W002 + (A2*P + B*W002)’ + 2*(beta)*P;
H31 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(alpha)*P;
H32 = [-Y (R^0.5)*W003; ((R^0.5)*W003)’ -P];
H33 = A3*P + B*W003 + (A3*P + B*W003)’ + 2*(beta)*P;
H41 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(alpha)*P;
H42 = [-Y (R^0.5)*W004; ((R^0.5)*W004)’ -P];
H43 = A4*P + B*W004 + (A4*P + B*W004)’ + 2*(beta)*P;
F = [P>=0]+[-H11<=0]+[H12<=0]+[H13<=gamma]+[H14<=0]+[-H21<=0]+[H22<=0]+[H23<=0]+[-H31<=0]+…
[H32<=0]+[H33<=0]+[-H41<=0]+[H42<=0]+[H43<=0]…
;
ops = sdpsettings(‘solver’,’sedumi’);
% ops = sdpsettings(‘solver’,’gurobi’);
[opt_info] = optimize(F,[],ops);
Pfeasible = value (P);
P_eigs = eig(Pfeasible);
result :
Error using eig
Input matrix contains NaN or Inf.
Error in DYNAMIC2 (line 69)
P_eigs = eig(Pfeasible); lmi lqr MATLAB Answers — New Questions