Adding PID controller to a MIMO state space system

If you want feedback a subset of the signals only, you use the advanced interface to feedback

  feedback(sys1::AbstractStateSpace, sys2::AbstractStateSpace;
           U1=:, Y1=:, U2=:, Y2=:, W1=:, Z1=:, W2=Int[], Z2=Int[],
           Wperm=:, Zperm=:, pos_feedback::Bool=false)
                ┌──────────────┐
        z1◄─────┤     sys1     │◄──────w1
   ┌─── y1◄─────┤              │◄──────u1 ◄─┐
   │            └──────────────┘            │
   │                                        α
   │            ┌──────────────┐            │
   └──► u2─────►│     sys2     ├───────►y2──┘
        w2─────►│              ├───────►z2
                └──────────────┘

It would look something like this

sysd = c2d(sys, C.Ts)
U1 = [1] # Index of the input of `sys1` that you want to connect
G = feedback(sysd, C; U1)

Set the other arguments to feedback as appropriate for what you want to include as inputs and outputs of the constructed feedback interconnection.

The output of G in my example above will be Z1 = :, that is, the output of the plant. The inputs will be W1 = :, that is, both inputs of the plant. If you want to keep only the unconnected input of the plant as input to the closed-loop system, set W1 = [2] (since you connected input [1] above).

2 Likes