w pendulum</span>
pendulum = [0, 0; l*sin(theta), -l*cos(theta)];
clf; hold <span class="string">on</span>
plot(pendulum(:,1), pendulum(:,2),<span class="string">'r'</span>,<span class="string">'linewidth'</span>,4)

<span class="comment">% plot ellipses around tips of pendulum (if M, S exist)</span>
<span class="keyword">try</span>
  <span class="keyword">if</span> max(max(S))&gt;0
    err = linspace(-1,1,100)*sqrt(S(2,2));
    plot(l*sin(M(2)+2*err),-l*cos(M(2)+2*err),<span class="string">'b'</span>,<span