Are there workaround to avoid "Cannot compute a stabilizing LQR gain" error?

I came across an error when I executed LQR command.
A = 5000;
B = 1e-6;
Q = 1e+4;
R = 1;
[F,P,~] = lqr(A,B,Q,R);
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,E) 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.
​However I could do calculation manually as follows. 
X = (A+(A^2+B^2*Q)^0.5 )/B^2 = 1.0000e+16
Are any workaround to calculate the X and K (gain) for the A, B? I want to set smaller number to Q, but he could not because of error.

 Accepted Answer

The error message does not indicate a theoretical inconsistency; it is caused by numerical instability.
When parameters such as A = 5000 and B = 1e-6 have a large ratio, computations in double precision become ill-conditioned. As a result, the algorithm may return an error because it cannot find a reliable solution.
​If A is a matrix, a very large condition number (cond(A)) means even small numerical errors can reduce solution accuracy.
Recommended actions:
  • Scale the model (normalize states and inputs, review units)
  • Use balanced realization (balreal) to improve conditioning
For ​the example system, following is oneof the workaround.
% Scaling: x2 = 1e6 * x
% dx2/dt = A * x2 + u
% cost = 1e-8 * x2^2 + u^2
[F, P, ~] = lqr(A, 1, 1e-8, 1);
% Optimum control equation: u = -K * x2 = -K * (1e6 * x)

More Answers (0)

Products

Release

R2024a

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!