NaN problem in MATLAB, LMI, disturbance rejection

26 views
Skip to first unread message

Andrea Weber

unread,
Apr 26, 2023, 3:26:05 AM4/26/23
to YALMIP
Hi,

can anyone help me? I'm trying to make the disturbance rejection in LMI for my TP model. If I run Matlab, F gain is NaN and I don't know where the problem is:
Warning: Matrix is singular, close to singular or badly scaled. Results may be inaccurate. RCOND = NaN.
 
Some important informations: 

E = diag([1 2 3 4]);
E = E(:, 1:2);

lmi.F = lmi.F + [1/2*(X*Ar'-M{s}'*Br'+Ar*X-Br*M{s}+X*As'-M{r}'*Bs'+As*X-Bs*M{r})-((1/2*X*(Cr+Cs)')*(eye(lmi.p)^(-1))*1/2*(Cr+Cs)*X)-(1/2*(E)*(((phi^2)*eye(lmi.p))^(-1))*1/2*(Cr+Cs)*X) >= 0];

Thank you!
Andrea
tanaka1.JPG

Johan Löfberg

unread,
Apr 26, 2023, 3:45:42 AM4/26/23
to YALMIP
As always, supply reproducible code (and tell us which solver you are using)

Andrea Weber

unread,
Apr 26, 2023, 5:07:37 AM4/26/23
to YALMIP
Okay, here are the codes and functions:

lmi = lmistructh(Sc, 4);
lmi = lmi_asymhi(lmi,0.23)
F   = lmi_solve(lmi);


function lmi = lmistructh(S, n)

I = size(S);
sizes = I(1:end-2);
R = prod(sizes);

S = reshape(S, [R I(end-1) I(end)]);

m = I(end) - n; 
p = I(end-1) - n; 
A = S(:, 1:n, 1:n);
B = S(:, 1:n, n+1:n+m);
C = S(:, n+1:n+p, 1:n);
D = S(:, n+1:n+p, n+1:n+m);


X = sdpvar(n, n, 'symmetric');
M = cell(1, R);
for r = 1:R
M{r} = sdpvar(m, n, 'full');
end

lmi.F = [X > 0];
lmi.sizes = sizes;
lmi.n = n;
lmi.m = m;
lmi.p = p;
lmi.A = A;
lmi.B = B;
lmi.C = C;
lmi.D = D;
lmi.X = X;
lmi.M = M;




function lmi = lmi_asymhi(lmi,gamma)

R = size(lmi.A, 1);
A = lmi.A;
B = lmi.B;
C = lmi.C;

E = diag([1 2 3 4]);
E = E(:, 1:2);
X = lmi.X;
M = lmi.M;
n = lmi.n;
m = lmi.m;
p = lmi.p;

for r = 1:R
for s = r+1:R
Ar = reshape(A(r,:,:), [n n]);
As = reshape(A(s,:,:), [n n]);
Br = reshape(B(r,:,:), [n m]);
Bs = reshape(B(s,:,:), [n m]);
                Cr = reshape(C(r,:,:), [p n]);
                Cs = reshape(C(s,:,:), [p n]);

 lmi.F = lmi.F + [1/2*(X*Ar'-M{s}'*Br'+Ar*X-Br*M{s}+X*As'-M{r}'*Bs'+As*X-Bs*M{r})-(1/2*X*(Cr+Cs)')*(eye(lmi.p)^(-1))*1/2*(Cr+Cs)*X-1/2*(E)*(((phi^2)*eye(lmi.p))^(-1))*1/2*(Cr+Cs)*X >= 0];

    end
end



function [F P] = lmi_solve(lmi)
%LMI_SOLVE

% solve
solvesdp(lmi.F);
checkset(lmi.F)

P = inv(double(lmi.X));
R = size(lmi.A, 1);
F = zeros(R, lmi.m, lmi.n);
for r = 1:R
F(r,:,:) = double(lmi.M{r}) * P;
end
F = reshape(F, [lmi.sizes lmi.m lmi.n]);

Johan Löfberg

unread,
Apr 26, 2023, 6:58:52 AM4/26/23
to YALMIP
To begin with, your code appears to have been written 10-15 years ago since it uses completely obsolete functions such as solvesdp, double and checkset

however, your code is not reproducible as you use local data
Reply all
Reply to author
Forward
0 new messages