title: Negative phase margin for stable system
body: <p>I want to determine the phase margin for the following transfer function:</p>
  
  <pre><code>sys_ol = tf([1.225 -1.1 -0.4183 0.3977],[1 -1.36 -0.4119 0.4019 0.9352 -0.565],1)
  </code></pre>
  
  <p>Its a discrete plant with sample time 1. By analysis of the poles I can see that the system is stable. Also building the closed loop system with unity feedback, by</p>
  
  <pre><code>sys_cl = feedback(sys_ol,1)
  </code></pre>
  
  <p>the closed loop system is stable. However, if I use Matlab's allmargin command on sys_ol, it returns:</p>
  
  <pre><code>GainMargin: 1.5073
  GMFrequency: 1.5206
  PhaseMargin: [34.1864 -27.7466 -179.7534]
  PMFrequency: [0.6973 2.0242 2.7058]
  DelayMargin: [0.8557 2.8648 1.1627 1]
  DMFrequency: [0.6973 2.0242 2.7058 3.1416]
       Stable: 1
  </code></pre>
  
  <p>So, according to "allmargin" there are two 0dB crossings that have a negative phase margin (-27.7deg / -179.8deg).</p>
  
  <p>To my understanding a system with negative phase margin is unstable. However pole analysis shows that the system is stable. Also "allmargin" gives "Stable: 1". How does this go together?</p>