24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
if n_q==n_y # Output weight
Q_x = C'*Q*C; # Weighting on x
elseif n_q==n_x # State weight
Q_x = Q;
else
error(sprintf("Q (%ix%i) must be %ix%i or %ix%i",n_q,n_q,n_y,n_y,n_x,n_x));
endif
Q_x
[k, P, poles] = lqr (A, B, Q_x, R) # Algebraic Riccati solution
## Basis functions
if strcmp(A_type,"companion")
A_u = compan(poly(poles));
elseif strcmp(A_type,"feedback")
A_u = A-B*k;
else
|
|
|
|
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
if n_q==n_y # Output weight
Q_x = C'*Q*C; # Weighting on x
elseif n_q==n_x # State weight
Q_x = Q;
else
error(sprintf("Q (%ix%i) must be %ix%i or %ix%i",n_q,n_q,n_y,n_y,n_x,n_x));
endif
[k, P, poles] = lqr (A, B, Q_x, R); # Algebraic Riccati solution
## Basis functions
if strcmp(A_type,"companion")
A_u = compan(poly(poles));
elseif strcmp(A_type,"feedback")
A_u = A-B*k;
else
|