8. Realizations

8.1 Irreducible (Minimal) Realizations

<< ControlSystems`

ss = 
      StateSpace[
        DiagonalMatrix[{(Subscript[a, 1]), (Subscript[a, 2]), (Subscript[a, 3])}], {{0, 0}, {(Subscript[b, 1]), 0}, {0, 
            (Subscript[b, 2])}}, {{(Subscript[c, 1]), 0, 0}, {0, 0, (Subscript[c, 3])}}, {{(Subscript[d, 11]), (Subscript[d, 12])}, {(Subscript[d, 21]), 
            (Subscript[d, 22])}}]

Controllable[ss]

Observable[ss]

ControllableSubsystem[ss]

ObservableSubsystem[ss]

ObservableSubsystem[%%]

MinimalRealization[ss]

Controllable[%] == Observable[%] == True

8.2 Kalman Canonical Forms

ss = 
      StateSpace[
        DiagonalMatrix[{(Subscript[a, 1]), (Subscript[a, 2]), (Subscript[a, 3])}], {{0, 0}, {(Subscript[b, 1]), 0}, {0, 
            (Subscript[b, 2])}}, {{(Subscript[c, 1]), 0, 0}, {0, 0, (Subscript[c, 3])}}, {{(Subscript[d, 11]), (Subscript[d, 12])}, {(Subscript[d, 21]), 
            (Subscript[d, 22])}}]

KalmanControllableForm[ss]

KalmanObservableForm[ss]

8.3 Jordan Canonical (Modal) Form

m = DiagonalMatrix[{-1, -2, -3}]

t = {{0, 1, 0}, {-1, 0, -1}, {1, -1, 0}}

Inverse[t] . m . t

ss = 
      StateSpace[
        DiagonalMatrix[{(Subscript[a, 1]), (Subscript[a, 2]), (Subscript[a, 3])}], {{0, 0}, {(Subscript[b, 1]), 0}, {0, 
            (Subscript[b, 2])}}, {{(Subscript[c, 1]), 0, 0}, {0, 0, (Subscript[c, 3])}}, {{(Subscript[d, 11]), (Subscript[d, 12])}, {(Subscript[d, 21]), 
            (Subscript[d, 22])}}]

ReplacePart[ss, %%, 1]

JordanCanonicalForm[%]

8.4 Internally Balanced Realizations

original = 
      StateSpace[{{0, 1, 0, 0}, {0, 0, 1, 0}, {0, 0, 0, 
              1}, {-50, -79, -33, -5}}, {{0}, {0}, {0}, {1}}, {{50, 15, 1, 0}}] // N

balanced = InternallyBalancedForm[%]

ControllabilityGramian[%] // Chop

ObservabilityGramian[%%] // Chop

TransferFunction[s, original] // ExpandRational // Chop

TransferFunction[s, balanced] // ExpandRational // Chop

8.5 Dominant Subsystem

reduced = DominantSubsystem[original]

reduced2 = 
      DominantSubsystem[balanced, RejectionLevel ->  .2]

DisplayTogetherGraphicsArray[
        BodePlot[original, PlotRange -> {All, {0, -600}}], 
        BodePlot[reduced, PlotStyle -> Dashing[{0.02}], 
          PlotPoints -> 75], 
        BodePlot[reduced2, 
          PlotStyle -> 
            Dashing[{0.05, 0.015, 0.005, 0.015}]]];

8.6 Pole-Zero Cancellation

TransferFunction[z, ((z -  .5)/( .5 - 1.5 z + (z^2))), 
      Sampled -> True]

PoleZeroCancel[%]

FactorRational[%%]

TransferFunction[s, ((s +  .5)/(s +  .4))]

PoleZeroCancel[%, Tolerance ->  .1]

8.7 Similarity Transformation

system  =  
      StateSpace[{{-3, 2, 0}, {0, -1, 0}, {1, -2, -2}}, {{0, 
            0}, {(Subscript[b, 1]), 0}, {0, (Subscript[b, 2])}}, {{(Subscript[c, 1]), 0, 0}, {0, 0, (Subscript[c, 3])}}, {{(Subscript[d, 11]), 
            (Subscript[d, 12])}, {(Subscript[d, 21]), (Subscript[d, 22])}}]

t = Eigenvectors[First[%]] // Transpose

SimilarityTransform[system, Inverse[t]]

SimilarityTransform[system, t, 
      InvertedTransformMatrix -> True]

8.8 Recovering the Transformation Matrix

system = 
      StateSpace[{{-3, 0, 0}, {0, -1, 0}, {1, -2, -2}}, {{0, 
            0}, {(Subscript[b, 1]), 0}, {0, (Subscript[b, 2])}}, {{(Subscript[c, 1]), 0, 0}, {0, 0, (Subscript[c, 3])}}, {{(Subscript[d, 11]), 
            (Subscript[d, 12])}, {(Subscript[d, 21]), (Subscript[d, 22])}}]

KalmanControllableForm[system]

TransformationMatrix[system, %]

SimilarityTransform[system, %, 
      OrthogonalTransformMatrix -> True]