I want to solve the Lyapunov equation with matlab
8 views (last 30 days)
Show older comments
Why, when I calculate R, I don't find -I? Thank you."
% Définition des matrices du système
A = [0 1;0 0];% Remplacez ... par la matrice A de votre système
B=[2;5];
K=[-0.131 -1.6874];
Ak=A+B*K;
E = [1 2;0 0]; % Remplacez ... par la matrice E de votre système
I = eye(size(A)); % Matrice identité de même taille que A
Q = [1 0 ;0 1]; % Remplacez ... par une matrice Q définie positive
% Fonction pour résoudre l'équation de Lyapunov avec la condition E
lyapunov_solve = @(P) (Ak'*P*E + E'*P*Ak + I)
% Initialisation de P
P0 = Q; % Vous pouvez également utiliser une autre initialisation si nécessaire
% Résolution de l'équation de Lyapunov avec la condition E
options = optimoptions('fsolve', 'Display', 'off'); % Options pour fsolve
Ps= fsolve(lyapunov_solve, P0, options)
% Vérification de la positivité de P
if all(eig(Ps) > 0)
disp('La matrice P est définie positive.');
else
disp('La matrice P n''est pas définie positive.');
end
R =Ak'*Ps*E + E'*Ps*Ak
0 Comments
Answers (2)
Torsten
on 27 Feb 2024
Use MATLAB's "lyap" or "dlyap".
1 Comment
Christine Tobler
on 28 Feb 2024
If you don't have Control Systems Toolbox, you can also look at the more generic sylvester function in base MATLAB.
Torsten
on 28 Feb 2024
Edited: Torsten
on 28 Feb 2024
You can also do it this way, but your system does not seem to have a solution:
% Définition des matrices du système
A = [0 1;0 0];% Remplacez ... par la matrice A de votre système
B=[2;5];
K=[-0.131 -1.6874];
Ak=A+B*K;
E = [1 2;0 0]; % Remplacez ... par la matrice E de votre système
I = eye(size(A)); % Matrice identité de même taille que A
Q = [1 0 ;0 1]; % Remplacez ... par une matrice Q définie positive
% Fonction pour résoudre l'équation de Lyapunov avec la condition E
P = sym('P',[2 2]);
eqns = Ak'*P*E + E'*P*Ak + I == 0;
[A,b] = equationsToMatrix(eqns)
sol = A\b
lyap(Ak.',I,[],E.')
0 Comments
See Also
Categories
Find more on Matrix Computations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!