m2 = [-l*sth1, l*cth1; -l*(sth1-sth2), l*(cth1+cth2)];
plot(pendulum1(:,1), pendulum1(:,2),'r','linewidth',4)
plot(pendulum2(:,1), pendulum2(:,2),'r','linewidth',4)

% plot target location
plot(0,2*l,'k+','MarkerSize',20);
plot([xmin, xmax], [-height, -height],'k','linewidth',2)
% plot inner joint
plot(0,0,'k.','markersize',24)
plot(0,0,'y.','markersize',14)
% plot outer joint
plot(-l*sth1, l*cth1,'k.','markersize',24)
plot(-l*sth1, l*cth1,'y.','markersize',14)
% plot tip of outer joint
plot(-l*(sth1-sth2),