3. Description of Dynamic Systems

3.1 Transfer Function Representations

<< ControlSystems`

TransferFunction[
      var, {{(2/(1 + (var^2))), (var/(var - 1))}}]

%[s]

%%[I 10. ]

\(TransferFunction[{{1\/#}}]\)

%[s]

\(TransferFunction[1\/#]\)

TransferFunction[
      s, {{(2/(1 + (s^2))), ((6 - 5 s + (s^2))/((s^4) - 1))}}]

FactorRational[%]

ExpandRational[%]

TransferFunction[s, (1/s) + (1/(s - 1))]

ExpandRational[%]

FactorRational[%%]

tf = TransferFunction[s, {{(2/(1 + (s^2))), (s/(s - 1))}}]

ZeroPoleGain[%]

TransferFunction[%]

FactorRational[tf]

ZeroPoleGain[{{{}}}, {{{0}}}, {{1}}]

TransferFunction[%]

TransferFunction[var, (1/(1 + (var^2)))]

% /. var -> z

3.2 State-Space Representations

StateSpace[{{(Subscript[a, 1]), (Subscript[a, 2])}, {(Subscript[a, 3]), (Subscript[a, 4])}}, {{(Subscript[b, 1])}, {(Subscript[b, 2])}}, {{(Subscript[c, 1]), 
          (Subscript[c, 2])}}]

StateSpace[{{(Subscript[a, 1]), (Subscript[a, 2])}, {(Subscript[a, 3]), (Subscript[a, 4])}}, {{(Subscript[b, 1])}, {(Subscript[b, 2])}}, {{(Subscript[c, 1]), 
          (Subscript[c, 2])}}, {{0}}]

SameQ @@ TransferFunction /@ {%, %%}

tf = TransferFunction[s, {{(1/(s - a)), (1/(s - b))}}]

StateSpace[%]

TraditionalForm[%]

MinimalRealization[%, ComplexVariables -> None] // Simplify // 
      TraditionalForm

StateSpace[tf, TargetForm -> ObservableCompanion] // 
      TraditionalForm

TransferFunction[s, #] & /@ {%, %%} // Simplify

3.3 Continuous-Time versus Discrete-Time Systems

ContinuousTimeQ[StateSpace[a, b, c]]

ContinuousTimeQ[StateSpace[a, b, c, Sampled -> True]]

ContinuousTimeQ[
      StateSpace[a, b, c, Sampled -> Period[T]]]

$Sampled = Period[1]

ContinuousTimeQ[StateSpace[a, b, c]]

$Sampled = False

3.4 The Traditional Notations

StateSpace[{{(Subscript[a, 1]), (Subscript[a, 2])}, {(Subscript[a, 3]), (Subscript[a, 4])}}, {{(Subscript[b, 1])}, {(Subscript[b, 2])}}, {{(Subscript[c, 1]), 
          (Subscript[c, 2])}}, Sampled -> True]

TraditionalForm[%]

\(TransferFunction[1\/#]\)

TraditionalForm[%]

ContinuousTimeQ[(Subscript[(({{(1/𝓈)}})), ""]^("𝒯"))]

StateSpace[{{(Subscript[a, 1]), (Subscript[a, 2])}, {(Subscript[a, 3]), (Subscript[a, 4])}}, {{(Subscript[b, 1])}, {(Subscript[b, 2])}}, {{(Subscript[c, 1]), 
          (Subscript[c, 2])}}]

EquationForm[%]

\(EquationForm[%, StateVariables -> {θ, θ\& . }, 
      InputVariables -> δ]\)

3.5 Discrete-Time Models of Continuous-Time Systems

tf = TransferFunction[s, (a/(s + a))]

hz = 
      ToDiscreteTime[%, Sampled -> Period[T]] // Simplify

% /. s -> z

(cont = StateSpace[{{0, 1}, {0, -1}}, {{0}, {1}}, {{1, 0}}]) // 
      TraditionalForm

disc = ToDiscreteTime[%, Sampled -> Period[τ]]

TraditionalForm[%]

OutputResponse[cont, Sin[t], t] // Simplify

Plot[%, {t, 0, 10}];

SimulationPlot[disc /. τ ->  .5, 
        Sin[t], {t, 0, 10}, PlotJoined -> False, 
        PlotStyle -> PointSize[ .015], 
        PlotLabel -> "Output Response", 
        Epilog -> First[%]];

3.5.1 The Conversion Methods

ToDiscreteTime[tf, Sampled -> Period[T], 
      Method -> ForwardRectangularRule]

ToDiscreteTime[tf, Sampled -> Period[T], 
        Method -> BackwardRectangularRule] // Simplify

ToDiscreteTime[tf, Sampled -> Period[T], 
        Method -> BilinearTransform] // Simplify

ToDiscreteTime[tf, Sampled -> Period[T], 
      Method -> ZeroPoleMapping]

ToDiscreteTime[TransferFunction[s, (1/(s^2))], Sampled -> Period[T], 
        Method -> FirstOrderHold] // Simplify

lag = TransferFunction[s, ((a s + 1)/(b s + 1))]

lagplot = 
        BodePlot[
          lag /. {a -> 1, b -> 5}];

dlag = 
      ToDiscreteTime[lag, Sampled -> Period[T], 
          Method -> BilinearTransform]  // Simplify

DisplayTogetherGraphicsArray[lagplot, 
        BodePlot[
          dlag /. {a -> 1, b -> 5, T -> 1}, 
          PlotStyle -> {RGBColor[1, 0, 0], 
              Dashing[{ .02}]}]];

ToDiscreteTime[lag, Sampled -> Period[T], 
        Method -> BilinearTransform, 
        CriticalFrequency -> (Subscript[ω, c])] // Simplify

DisplayTogetherGraphicsArray[lagplot, 
        BodePlot[% /. {a -> 1, b -> 5, 
              T -> 1, (Subscript[ω, c]) -> 2}, 
          PlotStyle -> {RGBColor[1, 0, 0], 
              Dashing[{ .02}]}]];

(lag1 = StateSpace[lag] // Simplify) // TraditionalForm

ToDiscreteTime[lag1, Sampled -> Period[T], 
          Method -> BilinearTransform] // Simplify // 
      TraditionalForm

3.6 Discrete-Time Models of Systems with Delay

ss = 
      StateSpace[{{1}}, {{1}}, {{1}}, Delay -> λ]

ToDiscreteTime[ss /. λ -> τ, 
      Sampled -> Period[τ]]

ToDiscreteTime[ss /. λ -> 2 τ, 
      Sampled -> Period[τ]]

ToDiscreteTime[
      ss /. λ -> -(τ/2), 
      Sampled -> Period[τ]]

3.7 Continuous-Time Models of Discrete-Time Systems

ToDiscreteTime[StateSpace[{{0, 1}, {0, -1}}, {{0}, {1}}, {{1, 0}}], 
      Sampled -> Period[T]]

ToContinuousTime[%]

ComplexExpand /@ %

lag1  =  
      StateSpace[{{-(1/b)}}, {{1}}, {{((-a + b)/(b^2))}}, {{(a/b)}}]

ToDiscreteTime[%, Sampled -> Period[T], 
        Method -> BilinearTransform, 
        CriticalFrequency -> (Subscript[ω, c])] // Simplify

ToContinuousTime[%, Method -> BilinearTransform, 
        CriticalFrequency -> (Subscript[ω, c])] // Simplify

ToDiscreteTime[lag1, Sampled -> Period[T], 
        Method -> FirstOrderHold] // Simplify

ToContinuousTime[%, Method -> FirstOrderHold] // 
      Simplify