Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- clf
- %Setup path
- s=0:.01:1;
- X=0.5+0.3*s+3.9*s.^2-4.7*s.^3;
- Y=1.5+0.3*s+0.9*s.^2-2.7*s.^3;
- plot(X,Y)
- hold all
- %Setup drawing
- set(gca,'XLim',[0 2],'YLim',[0 2], 'Drawmode', 'fast', 'visible', 'on');
- axis square
- ball=line('color','r','Marker','o','MarkerSize',10,'LineWidth',2,'erase','xor','xdata',[],'ydata',[]);
- ball2=line('color','b','Marker','o','MarkerSize',10,'LineWidth',2,'erase','xor','xdata',[],'ydata',[]);
- %Original Parameter
- t=.00:.05:20;
- t2 = zeros(20,1);
- %Constant Speed
- for i=0:20
- t2(i+1)=newtarclen(i*.05,.001);
- end
- a=0.5+0.3*t+3.9*t.^2-4.7*t.^3;
- b=1.5+0.3*t+0.9*t.^2-2.7*t.^3;
- c=0.5+0.3*t2+3.9*t2.^2-4.7*t2.^3;
- d=1.5+0.3*t2+0.9*t2.^2-2.7*t2.^3;
- filename = 'Problem5.gif';
- for i = 1:21
- set(ball,'xdata',a(i),'ydata',b(i));
- set(ball2,'xdata',c(i),'ydata',d(i));
- drawnow;
- pause(.1);
- frame = getframe(1);
- im = frame2im(frame);
- [imind,cm] = rgb2ind(im,256);
- if i == 1;
- imwrite(imind,cm,filename,'gif', 'Loopcount',inf);
- else
- imwrite(imind,cm,filename,'gif','WriteMode','append');
- end
- end
- clf
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement