title: How to use `feedback` function in Matlab?
body: <p>Matlab's feedback function is used to obtain the closed loop transfer function of a system. Example:</p>
  
  <p><a href="https://i.stack.imgur.com/q6eB6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/q6eB6.png" alt="enter image description here"></a></p>
  
  <p><code>sys = feedback(sys1,sys2)</code> returns a model object sys for the negative feedback interconnection of model objects <code>sys1</code>,<code>sys2</code>.  To compute the closed-loop system with positive feedback, use sign = +1, for negative feedback we use -1.</p>
  
  <p>My question arises when we have a system of the following type:</p>
  
  <p><a href="https://i.stack.imgur.com/20HX6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/20HX6.png" alt="enter image description here"></a></p>
  
  <p>According to these <a href="https://www.mathworks.com/help/control/ref/feedback.html#d117e51709" rel="nofollow noreferrer">docs</a>, we can use feedback to create the negative feedback loop with G and C.</p>
  
  <pre><code>sys = feedback(G*C,-1)
  </code></pre>
  
  <p>This is a source of confusion, shouldn't the above be:  <code>sys = feedback(G*C,1,-1)?</code> These are not the same.</p>
  
  <p>However, looking at these <a href="https://www.mathworks.com/help/control/ug/assessing-gain-and-phase-margins.html" rel="nofollow noreferrer">docs</a>, for a unit loop gain k, you can compute the closed-loop transfer function T using:</p>
  
  <pre><code>G = tf([.5 1.3],[1 1.2  1.6 0]);
  T = feedback(G,1); 
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/vxVVi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vxVVi.png" alt="enter image description here"></a></p>
  
  <p>Why are we using  <code>1</code> and not <code>-1</code>? This is still negative feedback and not positive feedback.</p>