Differences From Artifact [36a7ac48d8]:

To Artifact [61fa06621b]:


9
10
11
12
13
14
15





16
17
18

19






20
21
22
23
24
25
26
27
    return
  endif
  
  if nargin<7
    A_type = "feedback";
  endif
  






  ## Steady-state Linear Quadratic solution
  ## using Algebraic Riccati equation (ARE)

  Q_x =  C'*Q*C;			# Weighting on 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







>
>
>
>
>
|


>
|
>
>
>
>
>
>
|







9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
    return
  endif
  
  if nargin<7
    A_type = "feedback";
  endif
  
  [n_x,n_u,n_y] = abcddim(A,B,C,D); # Dimensions
  n_q = is_square(Q);		# Size of Q
  if n_q==0
    error("Q must be square");
  endif
  
  ## Steady-state Linear Quadratic solution
  ## using Algebraic Riccati equation (ARE)
  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

MTT: Model Transformation Tools
GitHub | SourceHut | Sourceforge | Fossil RSS ]