DESIGN OF STATE VARIABLE FEEDBACK AND
STATE OBSERVER
                                                   𝑌(𝑆)      9
 1) The open-loop transfer function of a system is 𝑈(𝑆) = 𝑆 2 −9. Compute
    the state-variable feedback gain vector which places the closed-
    loop system at −3 ± 𝑗3.
    PROCEDURE
       a) Arbitrary state-variable feedback is possible if and only if the
          given system is controllable. So check the controllability of
          the given system by checking the rank of the controllability
          matrix 𝑈𝐶 where rank of 𝑈𝐶 must be equal to the order of the
          system n. controllabilitymatrix 𝑈𝐶 = [𝐵 𝐴𝐵 ⋯ 𝐴𝑛−1 𝐵].
       b) From the characteristic polynomial of matrix A:
                 |𝑆𝐼 − 𝐴| = 𝑆 𝑛 + 𝛼1 𝑆 𝑛−1 + ⋯ ⋯ + 𝛼𝑛−1 𝑆 + 𝛼𝑛 .
          Determine the values 𝛼1 , 𝛼2 , ⋯ , 𝛼𝑛−1 , 𝛼𝑛 .
       c) Determine the transformation matrix P that transforms the
          system 𝑥´(𝑡) = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡) into controllable canonical form:
                         𝑃1
                        𝑃1 𝐴
                 𝑃=[          ]
                          ⋮
                      𝑃1 𝐴𝑛−1
                 𝑃1 = [0 0 0 ⋯ 1]𝑈𝐶−1
          Using the desired specifications find the desired characteristic
          polynomial 𝑆 𝑛 + 𝑎1 𝑆 𝑛−1 + ⋯ ⋯ + 𝑎𝑛−1 𝑆 + 𝑎𝑛 .
          Determine the values of 𝑎1 , 𝑎2 , ⋯ , 𝑎𝑛−1 , 𝑎𝑛 .
       d) The required state-variable feedback gain vector is
                 𝐾 = [(𝑎𝑛 − 𝛼𝑛 ) (𝑎𝑛−1 − 𝛼𝑛−1 ) ⋯    (𝑎1 − 𝛼1 )]𝑃
       e) State variable representation of the uncompensated system is
                           𝑥´(𝑡) = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡); 𝑦(𝑡) = 𝐶𝑥(𝑡)
          State variable representation of the compensated system is
                       𝑥´(𝑡) = [𝐴 − 𝐵𝐾]𝑥(𝑡) = 𝐴𝐴𝑥(𝑡); 𝑦(𝑡) = 𝐶𝑥(𝑡)
    PROGRAM (Save as poleplacement.m)
        num = [9];den = [1 0 -9]; sys = tf(num , den)
        [A , B , C , D] = tf2ss(num , den)
        UC = [B A*B] %Controllability matrix
          rank(UC)
          order(sys)
          P1 = [0 1]*inv(UC);
          P = [P1 ; P1*A]
          alpha = poly(A)
          alpha1 = alpha(2)
          alpha2 = alpha(3)
          a = conv([1 3+j*3] , [1 3-j*3])
          a1 = a(2)
          a2 = a(3)
          K = [(a2 – alpha2) (a1 – alpha1)]*P
2) For the above system, design a full order state observer such that
   the observer error poles are located at −6 ± 𝑗6.
   PROCEDURE
      a) Design of full order state observer is possible if and only if
         the state variable representation is observable, or the duel of
         the state variable representation is controllable. Find 𝐴𝑑 =
         𝐴𝑇 ; 𝐵𝑑 = 𝐶 𝑇 ; 𝐶𝑑 = 𝐵𝑇 ; 𝐷𝑑 = 𝐷 𝑇 . So check the controllability of
         the dual of the given system by checking the rank of the
         controllability matrix 𝑈𝐶 where rank of 𝑈𝐶 must be equal to
         the order of the system n. controllability matrix 𝑈𝐶 =
         [𝐵𝑑 𝐴𝑑𝐵𝑑 ⋯ 𝐴𝑑𝑛−1 𝐵𝑑].
      b) From the characteristic polynomial of matrix Ad:
                 |𝑆𝐼 − 𝐴𝑑| = 𝑆 𝑛 + 𝛼1 𝑆 𝑛−1 + ⋯ ⋯ + 𝛼𝑛−1 𝑆 + 𝛼𝑛 .
         Determine the values 𝛼1 , 𝛼2 , ⋯ , 𝛼𝑛−1 , 𝛼𝑛 .
      c) Determine the transformation matrix Pd that transforms the
         system 𝑥´(𝑡) = 𝐴𝑑𝑥(𝑡) + 𝐵𝑑𝑢(𝑡) into controllable canonical form:
                            𝑃1
                          𝑃1 𝐴𝑑
                 𝑃𝑑 = [            ]
                             ⋮
                               𝑛−1
                        𝑃1 𝐴𝑑
                 𝑃1 = [0 0 0 ⋯ 1]𝑈𝐶−1
         Using the desired specifications find the desired characteristic
         polynomial 𝑆 𝑛 + 𝑎1 𝑆 𝑛−1 + ⋯ ⋯ + 𝑎𝑛−1 𝑆 + 𝑎𝑛 .
         Determine the values of 𝑎1 , 𝑎2 , ⋯ , 𝑎𝑛−1 , 𝑎𝑛 .
      d) State-variable feedback gain vector is
               𝐾𝑑 = [(𝑎𝑛 − 𝛼𝑛 ) (𝑎𝑛−1 − 𝛼𝑛−1 ) ⋯ (𝑎1 − 𝛼1 )]𝑃𝑑
      e) The require observer vector is
                                             𝑚 = 𝐾𝑑𝑇
      f) State variable representation of the given system is
                           𝑥´(𝑡) = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡); 𝑦(𝑡) = 𝐶𝑥(𝑡)
         State variable representation of state observer is
               𝑥^´(𝑡) = 𝐴𝑥^(𝑡) + 𝐵𝑢(𝑡) + 𝑚𝐶[𝑥(𝑡) − 𝑥^(𝑡)]
         State variable representation of observer error system is
               𝑥´𝑒 (𝑡) = [𝐴 − 𝑚𝐶]𝑥𝑒 (𝑡); 𝑥𝑒 (𝑡) = 𝑥(𝑡) − 𝑥𝑒 (𝑡)
         State variable representation of the combined system is
                𝑥´(𝑡)   𝐴         0        𝑥(𝑡)      𝑏
               [´ ] = [                 ][      ] + [ ] 𝑢(𝑡);
                𝑥^(𝑡)  𝑚𝐶      𝐴 − 𝑚𝐶 𝑥^(𝑡)          𝑏
                                  𝑦(𝑡)       𝐶 0 𝑥(𝑡)
                                 [      ]=[         ][    ]
                                  𝑦^(𝑡)      0 𝐶 𝑥^(𝑡)
   PROGRAM (Save as stateobserver.m)
       num = 9; den = [1 0 -9]; sys = tf(num , den)
       [A , B , C , D] = tf2ss(num , den)
       Ad=A’ ,Bd=C’ , Cd=B’ , Dd=D’
       UC1 = [Bd Ad*Bd] %Controllability matrix
       rank(UC1)
       order(sys)
       P1 = [0 1]*inv(UC1);
       P = [P1 ; P1*Ad]
       alpha = poly(Ad)
       alpha1 = alpha(2)
       alpha2 = alpha(3)
       a = conv([1 6+j*6] , [1 6-j*6])
       a1 = a(2)
       a2 = a(3)
       Kd = [(a2 – alpha2) (a1 – alpha1)]*P
       m = Kd’
3) For the above system, design a state variable feedback where the
   state variables of the system are not available for feedback. The
   state-variable feedback gain vector places the closed loop system
   at −3 ± 𝑗3. The observer error poles are located at −6 ± 𝑗6.
PROCEDURE
  a) The design of state-variable feedback and full order state
     observer is independently possible by the “Separation
     Principle”. Therefore use the above two procedure
     respectively.
  b) State variable representation of the given system is
                       𝑥´(𝑡) = 𝐴𝑥(𝑡) + 𝐵𝑢(𝑡); 𝑦(𝑡) = 𝐶𝑥(𝑡)
     State variable representation of state observer is
           𝑥^´(𝑡) = 𝐴𝑥^(𝑡) + 𝐵𝑢(𝑡) + 𝑚𝐶[𝑥(𝑡) − 𝑥^(𝑡)]
     State variable representation of observer error system is
           𝑥´𝑒 (𝑡) = [𝐴 − 𝑚𝐶]𝑥𝑒 (𝑡); 𝑥𝑒 (𝑡) = 𝑥(𝑡) − 𝑥𝑒 (𝑡)
     State variable representation of the combined system is
            𝑥´(𝑡)   𝐴         0        𝑥(𝑡)      𝑏
           [´ ] = [                 ][      ] + [ ] 𝑢(𝑡);
            𝑥^(𝑡)  𝑚𝐶      𝐴 − 𝑚𝐶 𝑥^(𝑡)          𝑏
                              𝑦(𝑡)       𝐶 0 𝑥(𝑡)
                             [      ]=[         ][    ]
                              𝑦^(𝑡)      0 𝐶 𝑥^(𝑡)
     where 𝑢(𝑡) = −𝐾𝑥^(𝑡).
  c) Therefore the combined system after the state variable is
                       𝑥´(𝑡)     𝐴        −𝑏𝐾       𝑥(𝑡)
                      [´ ] = [                    ][    ];
                       𝑥^(𝑡)    𝑚𝐶 𝐴 − 𝑚𝐶 − 𝑏𝐾 𝑥^(𝑡)
                              𝑦(𝑡)     𝐶 0 𝑥(𝑡)
                             [      ]=[     ][   ]
                              𝑦^(𝑡)     0 𝐶 𝑥^(𝑡)
PROGRAM
    poleplacement.m
    stateobserver.m