Use symbolic variable for lyapunov function
조회 수: 9 (최근 30일)
이전 댓글 표시
I am trying to find a value for a lyapunov function but I do not know the numeric values. When I run the lyapunov command, I get an error that only numeric arrays can be used. Is there a way for using only symbolic variable to get the answer.
댓글 수: 4
Sam Chak
2022년 3월 9일
I have tested and verified the results symbolically that holds.
clear all; clc
syms a b c
A = sym('A', [3 3]); % state matrix
P = sym('P', [3 3]); % positive definite matrix
A = [sym('0') sym('1') sym('0');
-a -b sym('0');
sym('0') c -c];
P = [((a^3 + 2*a^2*b*c + 2*a^2*c^2 + a^2 + a*b^2 + a*b*c + a*c^2 + b^3*c + b^2*c^2)/(2*a*b*(c^2 + b*c + a))) (1/(2*a)) (-a/(2*(c^2 + b*c + a)));
(1/(2*a)) ((a^2 + 2*a*c^2 + b*a*c + a + c^2 + b*c)/(2*a*b*(c^2 + b*c + a))) (c/(2*(c^2 + b*c + a)));
(-a/(2*(c^2 + b*c + a))) (c/(2*(c^2 + b*c + a))) (1/(2*c))];
Q = sym(eye(3)); % identity matrix
L = A.'*P + P*A + Q; % Lyapunov equation
simplify(L)
Result:
채택된 답변
Sam Chak
2022년 3월 9일
If you are writing for a journal paper or a thesis, the following explanation might be helpful.
Let , , and .
There are a few ways to solve this symbolically.
syms a b c p11 p12 p22 p23 p33 p31
eqns = [1 - 2*a*p12 == 0, - a*p22 - b*p12 + c*p31 + p11 == 0, 1 - 2*b*p22 + 2*c*p23 + 2*p12 == 0, - b*p23 - c*p23 + c*p33 + p31 == 0, 1 - 2*c*p33 == 0, - a*p23 - c*p31 == 0];
S = solve(eqns);
sol = [S.p11; S.p12; S.p22; S.p23; S.p33; S.p31]
Result:
The result has been verified numerically:
clear all; clc
A = [0 1 0; -1 -2 0; 0 1 -1]
Q = eye(3)
P = lyap(A', Q)
A'*P + P*A
댓글 수: 5
Sam Chak
2022년 3월 9일
편집: Sam Chak
2022년 3월 9일
Hi @Torsten
My apologies for failing to inform that P has to be a symmetric matrix . Allow me to quote the theorem directly from Prof. Hassan Khalil's book, "Nonlinear Control":
Theorem: A matrix A is Hurwitz if and only if for every positive definite symmetric matrix Q, there exists a positive definite symmetric matrix P that satisfies the Lyapunov equation . Moreover, if A is Hurwitz, then P is the unique solution.
From the property of symmetry, we know that , , and .
I'm still learning and not good at expressing the control law and equations in the symbolic form in MATLAB. That's why I worked out the equations manually and then used MATLAB to solve the derived set of linear equations. Thanks for your original script in solving the symbolic equations.
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Computations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!