Dimension issues #1417
Replies: 1 comment 1 reply
-
well, precisely as it says, your dimensions are broken This matrix fails to be constructed. Hence comment out rows and try to create it and when it no longer fails to be constructed you know where you are wrong Your construction of LMI2 will also fail due to dimension mismatch as the (1,1) block trivially must be scalar Your code should not even run in a recent version of YALMIP even if fixed, as strict inequalities simply should raise an error (old versions raised a warning) Finally, you appear to miss what L stands for in LMI. LMI3 is not an LMI as it is nonlinear in gamma0 and sclr0 |
Beta Was this translation helpful? Give feedback.
-
Hello, I hope this message finds you well. I have been trying to solve the following LMI (this is my first time solving a big LMI like this ), i tried two different approaches but i always have some errors regarding the dimensions, number of rows or something of the sort:


the following is the two codes i used:
Approach 1:
`% Clear workspace
clear all
% Define constants
Ix = 20;
Iy = 18;
Iz = 15;
h = 300; % height in km
w0 = 0.0011587; % orbital frequency f=0.00113 rad/s
t = 0:0.01:20;
x0 = [0.08, 0.06, -0.06, 0.01, 0.01, 0.01]; % x(0)
um1 = 0.25;
um2 = um1;
um3 = um1;
% Define matrices
M1 = [0.8 1.1 1.3 1.5 1.6 1.8].';
N1 = [-0.1 -0.2 -0.3 -0.4 -0.2 1];
M2 = [1 1 1].';
N2 = [0.1 0.1 0.1 0.1 0.1 0.1];
M3 = [0.1 0.1 0.1].';
a = ones(6,3);
N3 = (10^-3) * a;
A41 = -4*(w0^2)(Ix^-1)(Iy-Iz);
A52 = -3*(w0^2)(Iy^-1)(Ix-Iz);
A63 = -w0^2*(Iz^-1)(Iy-Ix);
A = [0 0 0 1 0 0;
0 0 0 0 1 0;
0 0 0 0 0 1;
A41 0 0 0 0 -w0(Ix^-1)(Iy-Ix-Iz);
0 A52 0 0 0 0;
0 0 A63 w0(Iz^-1)*(Iy-Ix-Iz) 0 0];
B1 = [zeros(3) diag([Ix^-1, Iy^-1, Iz^-1])].';
B2 = B1;
D2 = [zeros(1,4) -w0 0].';
II = eye(3);
B = [0 0 -w0;
0 0 0;
w0 0 0];
C1 = [II zeros(3);
B II];
C2 = [eye(6)];
D1 = B1;
d = 6 * [10^-5 10^-5 10^-5].'; % d(t)=g(t)
e1 = 0.025;
e2 = 0.022;
gamma = 0.1;
epsi = 0.001;
no = 0.1;
% Define variables
X = sdpvar(size(A,1), size(A,1), 'symmetric');
W = sdpvar(size(B1,2), size(A,1));
gamma0 = sdpvar(1,1);
sclr0 = sdpvar(1,1);
% Check sizes of each block in LMI1
disp('Sizes of each block in LMI1:');
disp(size(AX + B1W + XA' + W'B1')); % Should be 6x6
disp(size(M1)); % Should be 6x1
disp(size(XN1')); % Should be 6x1
disp(size(B1M2)); % Should be 6x3
disp(size(XN2')); % Should be 6x1
disp(size(XC2')); % Should be 6x6
disp(size(B2)); % Should be 6x6
% Define LMI1 using blkdiag
LMI1 = blkdiag(AX + B1W + XA' + W'B1', -(e1^(-1))eye(size(M1,1)), -e1eye(size(N1,1)), -(e2^(-1))eye(size(B1,1)), -e2eye(size(N2,1)), -eye(size(C2,1)), -gamma^2eye(size(B2,1))) + ...
[zeros(size(A,1)), M1, XN1', B1M2, XN2', XC2', B2;
M1', zeros(size(M1',1),size(M1',1)), zeros(size(M1',1),size(N1',1)), zeros(size(M1',1),size(B1,1)), zeros(size(M1',1),size(N2,1)), zeros(size(M1',1),size(C2',1)), zeros(size(M1',1),size(B2,1));
N1X, zeros(size(N1,1),size(M1,1)), zeros(size(N1,1),size(N1,1)), zeros(size(N1,1),size(B1,1)), zeros(size(N1,1),size(N2,1)), zeros(size(N1,1),size(C2,1)), zeros(size(N1,1),size(B2,1));
(B1M2)', zeros(size(B1,1),size(M1,1)), zeros(size(B1,1),size(N1,1)), zeros(size(B1,1),size(B1,1)), zeros(size(B1,1),size(N2,1)), zeros(size(B1,1),size(C2,1)), zeros(size(B1,1),size(B2,1));
N2X, zeros(size(N2,1),size(M1,1)), zeros(size(N2,1),size(N1,1)), zeros(size(N2,1),size(B1,1)), zeros(size(N2,1),size(N2,1)), zeros(size(N2,1),size(C2,1)), zeros(size(N2,1),size(B2,1));
C2*X, zeros(size(C2,1),size(M1,1)), zeros(size(C2,1),size(N1,1)), zeros(size(C2,1),size(B1,1)), zeros(size(C2,1),size(N2,1)), zeros(size(C2,1),size(C2,1)), zeros(size(C2,1),size(B2,1));
B2', zeros(size(B2',1),size(M1,1)), zeros(size(B2',1),size(N1,1)), zeros(size(B2',1),size(B1,1)), zeros(size(B2',1),size(N2,1)), zeros(size(B2',1),size(C2,1)), zeros(size(B2',1),size(B2',1))] < 0;
% Define LMI2
LMI2 = [-gamma0*eye(length(x0)), (x0).'; ...
x0, -X] < 0;
% Define LMI3
LMI3 = [-X, W.', X.';
W, -sclr0*(gamma0^(-1))eye(size(W, 1))+(epsi^(-1))(no^2)*eye(size(W, 1)), zeros(size(W, 1), size(X, 2));
X, zeros(size(X, 1), size(W, 1)), -(epsi^(-1))*eye(size(X, 1))] < 0;
% Collect all LMIs
Constraints = [LMI1, LMI2, LMI3];
% Optimization options
options = sdpsettings('solver', 'sedumi', 'verbose', 1);
optimize(Constraints, sclr0, options);
% Get the optimized values
X_value = value(X);
W_value = value(W);
gamma0_value = value(gamma0);
sclr0_value = value(sclr0);
% Display the results
disp('Optimized values:');
disp('X = ');
disp(X_value);
disp('W = ');
disp(W_value);
disp('gamma0 = ');
disp(gamma0_value);
disp('sclr0 = ');
disp(sclr0_value);
% Calculate the controller gain matrix K
K = W_value / X_value;
disp('K = ');
disp(K);`
Beta Was this translation helpful? Give feedback.
All reactions