I am trying to plot the trajectory of P4 as it travels in the animation.
hold onaxis equalaxis offb = 0:pi/60:pi/6;c = 0:pi/30:pi/3;d = 0:pi/20:pi/2;for k = 1:numel(b) P1=[-15,0]; P2=[-5,0]; plot([P1(1) P2(1)],[P1(2) P2(2)],'LineWidth',5,'Color','black'); A=[0,0]; h{1} = viscircles(A,5,'LineWidth',2,'Color','black'); B = A+[10*cos(b(k)-pi/6),10*sin(b(k)-pi/6)]; h{2} = viscircles(B,5,'LineWidth',2,'Color','green'); C = B+[10*cos(c(k)-pi/3),10*sin(c(k)-pi/3)]; h{3} = viscircles(C,5,'LineWidth',2,'Color','blue'); D = C+[10*cos(d(k)-pi/2),10*sin(d(k)-pi/2)]; h{4} = viscircles(D,5,'LineWidth',2,'Color','red'); P3=D+[5*cos(d(k)-(pi/2)),5*sin(d(k)-(pi/2))]; P4=D+[15*cos(d(k)-(pi/2)),15*sin(d(k)-(pi/2))]; h{5} = plot([P3(1) P4(1)],[P3(2) P4(2)],'LineWidth',5,'Color','black'); drawnow(); pause(0.5); delete( vertcat(h{:}) );endhold offaxis equalaxis off
Best Answer