How to get output results when using the lqr command in matlab
Show older comments
I have a linear system where A is 3 x 3 and B is 3 x 1.
Ak = 1 6.7514e-15 -2.6163e-15
-0.0075042 1 -0.027778
1.4838 0.0096057 0.9984
Bk = -3.4564e-16
29.996
-3.3325
I want to use the lqr command to generate optimal K gains, but when I look at the rank of the controllability matrix, it is only 2:
cont_matrix = ctrb(Ak, Bk);
controllability_rank = rank(cont_matrix);
Size of the controllability matrix for matrices A and B:
3 3
Rank of controllability matrix for matrices A and B:
2
--> I "think" the rank of the controllability matrix needs to be 3, if I want the system to be controllable (is this correct?).
I have also picked simple Q and R matrices for now:
temp_vector_v = ones(size(Ak,1),1);
Qk = diag(temp_vector_v);
Rk = 1;
As a result of the above, when I use the lqr command, I get the following error:
lqr(Ak, Bk, Qk, Rk);
Error using lqr (line 42)
Cannot compute a stabilizing LQR gain (the Riccati solution S and gain matrix K are infinite).
This could be because:
* A has unstable modes that are not controllable through B,
* Q,R,N values are too large,
* [Q N;N' R] is indefinite,
* The E matrix in the state equation is singular.
==> I have seen this error discussed before on the forums. What are some things I can do to try and get Matlab to generate optimal K gains using the lqr function, instead of throwing this error?
Accepted Answer
More Answers (1)
richard
on 14 Jun 2023
1 vote
Categories
Find more on Control System Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!