ol></div><h2>Code<a name="2"></a></h2><pre class="codeinput"><span class="comment">% Loop over states in trajectory</span>
<span class="keyword">for</span> r = 1:size(xx,1)
  cost.t = r;
  <span class="keyword">if</span> exist(<span class="string">'j'</span>,<span class="string">'var'</span>) &amp;&amp; ~isempty(M{j})
    draw_pendubot(latent{j}(r,3), latent{j}(r,4), latent{j}(r,end), cost,  <span class="keyword">...</span>
      [<span class="string">'trial # '</span> num2str(j+J) <span class="string">', T