How to plot/draw a cross sign with 5 (x,y) coordinate,the center point change with time, with out plotting all 5 point every time
Show older comments
Dear User Community I would like to plot/draw a cross sign according to 5 coordinate. The situation is I want to simulate a mass ball attach with springs in 4 directions to the walls like this figure <<<http://poi.sagepub.com/content/31/1/62/F3.small.gif>>> and then simulate the ball movement with time. Now I can only draw the moving ball. If I want to draw the lines as the springs I have to redraw 5 points; 4 at walls 1 at ball, every frame of simulation. Now my code looks like this (only the graphical part)
h=plot(0,0,'MarkerSize',30,'Marker','.','LineWidth',2); w_h=4; axis([-w_h w_h -w_h w_h]); axis square; line([-4 -4],[-5 5],'Color','r','LineWidth',4);%wall line([4 4],[-5 5],'Color','r','LineWidth',4);%wall set(gca,'nextplot','replacechildren'); xlabel('X');ylabel('Y');
for i=1:length(X)-1 if (ishandle(gca)==1) Xcoord=X(1,i); Ycoord=X(2,i);
set(h,'XData',Xcoord,'YData',Ycoord);
drawnow;
pause(t(i+1)-t(i));
end
end
Is there any way I could replace just the center coordinate and still have the lines attach to the non-replace coordinate.
Thanks,
Answers (0)
Categories
Find more on Geometric Geodesy in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!