# State space feedback

**URL:** https://discourse.julialang.org/t/state-space-feedback/92416
**Category:** General Usage
**Tags:** controlsystems
**Created:** [January 2, 2023, 1:37pm UTC](https://discourse.julialang.org/t/state-space-feedback/92416 "2023-01-02T13:37:20Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![baggepinnen](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/baggepinnen/32/693_2.png) [@baggepinnen](https://discourse.julialang.org/u/baggepinnen)
#### Post date: [January 2, 2023, 2:02pm UTC](https://discourse.julialang.org/t/state-space-feedback/92416/3 "2023-01-02T14:02:15Z")

</div>

Hello and welcome to the forum!

Please read [Please read: make it easier to help you](https://discourse.julialang.org/t/please-read-make-it-easier-to-help-you/14757) to learn how to quote your code, and try to include code for an example that runs 🙂

When you index `back[1,1]` you get a SISO system, you must somehow account for the second output of `Model` before you call `feedback`, i.e., by making `C` a 1x2 system?

Alternatively, if you want `C` to operate on one of the outputs only, but keep the second output when you form the closed-loop system, you need to use the advanced interface to `feedback` where you specify which inputs and outputs are involved in the feedback, and which are considered external.

```julia
  feedback(sys1::AbstractStateSpace, sys2::AbstractStateSpace;
           U1=:, Y1=:, U2=:, Y2=:, W1=:, Z1=:, W2=Int[], Z2=Int[],
           Wperm=:, Zperm=:, pos_feedback::Bool=false)

  Basic use feedback(sys1, sys2) forms the feedback
  interconnection

             ┌──────────────┐
  ◄──────────┤ sys1 │◄──── Σ ◄──────
      │ │ │ │
      │ └──────────────┘ -1
      │ |
      │ ┌──────────────┐ │
      └─────►│ sys2 ├──────┘
             │ │
             └──────────────┘

  Advanced use feedback also supports more flexible use according
  to the figure below

                ┌──────────────┐
        z1◄─────┤ sys1 │◄──────w1
   ┌─── y1◄─────┤ │◄──────u1 ◄─┐
   │ └──────────────┘ │
   │ α
   │ ┌──────────────┐ │
   └──► u2─────►│ sys2 ├───────►y2──┘
        w2─────►│ ├───────►z2

```

in your case, you would have to provide `Z1 = :` and `Y1=[1]` or `Y1=[2]` depending on which output is fed back to the controller, e.g.,

```julia
feedback(Model, C, Y1=[1])

```

---

_[View the full topic](https://discourse.julialang.org/t/state-space-feedback/92416)._
