title: PID Compensation in Matlab
body: <p>Im trying to design a PID compensator with Matlab.
  I'm doing the following:</p>
  
  <p>My plant has this transfer function:</p>
  
  <pre><code>plant 
  
  
         ( 0.0195 s - 6.5  )/ (1.74e-06 s^2 - 0.003 s - 1)
  </code></pre>
  
  <p>So, using the PID tune function, specifying the desired crossover frequency:</p>
  
  <pre><code>&gt;&gt; [info,pid_c] = pidtune(plant,'PID',(2E6/6)*2*pi)
  
  info =
  
  
    Kp + Ki * 1/s
  
  
    with Kp = 162, Ki = 1.96e+08
  
  Continuous-time PI controller in parallel form.
  
  
  pid_c =
  
                  Stable: 1
      CrossoverFrequency: 2.0944e+06
             PhaseMargin: 60.0000
  </code></pre>
  
  <p>But, when I close the loop and analyse the poles of the system I see that there's a pole in the right semi-plane:</p>
  
  <pre><code>&gt;&gt; pid_c = 162 + 1.96E8/s
  
  pid_c =
  
  (  162 s + 1.96e08 ) /  s
  
  Continuous-time transfer function.
  
  &gt;&gt; sys=feedback(plant*pid_c,1)
  
  sys =
  
           (3.159 s^2 + 3.821e06 s - 1.274e09 )/ ( 1.74e-06 s^3 + 3.156 s^2 + 3.821e06 s - 1.274e09)
  
  Continuous-time transfer function.
  
  &gt;&gt; pole(sys)
  
  ans =
  
     1.0e+06 *
  
    -0.9071 + 1.1721i
  
    -0.9071 - 1.1721i
  
     0.0003 &lt;==== RSP pole
  </code></pre>
  
  <p>My intuition says I should get away with this pole by adding a (s+0.0003) to the numerator of the PID:</p>
  
  <pre><code>&gt;&gt; pid_c=pid_c*(s+0.0003)
  
  pid_c =
  
  (  162 s^2 + 1.96e08 s + 5.88e04 )/  s
  </code></pre>
  
  <p>But it doesnt work at all, and the tranfer function of my closed-loop goes like that:</p>
  
  <pre><code>sys =
  
    (3.159 s^3 + 3.821e06 s^2 - 1.274e09 s - 3.822e05) /  (3.159 s^3 + 3.821e06 s^2 - 1.274e09 s - 3.822e05)
  </code></pre>
  
  <p>and off course thats wrong.</p>
  
  <p>I really appreciate your help.</p>