ent">% Draw double pendulum</span>
clf; hold <span class="string">on</span>
sth1 = sin(theta1); sth2 = sin(theta2);
cth1 = cos(theta1); cth2 = cos(theta2);
pendulum1 = [0, 0; -l*sth1, l*cth1];
pendulum2 = [-l*sth1, l*cth1; -l*(sth1-sth2), l*(cth1+cth2)];
plot(pendulum1(:,1), pendulum1(:,2),<span class="string">'r'</span>,<span class="string">'linewidth'</span>,4)
plot(pendulum2(:,1), pendulum2(:,2),<span class="string">'r'</span>,<span class="string">'linewidth'</span>,4)

<span class="comment">% plot targe