Skip to content

Instantly share code, notes, and snippets.

@moorepants
Created June 3, 2011 23:33
Show Gist options
  • Save moorepants/1007366 to your computer and use it in GitHub Desktop.
Save moorepants/1007366 to your computer and use it in GitHub Desktop.
Basic Matlab Animation
t = 0:0.001:1000;
x = cos(t);
y = sin(t);
fig = figure();
ax = axes();
hold on
dot1 = plot(x(1), y(1));
dot2 = plot(1.5 * x(1), 1.5 * y(2));
hold off
set([dot1, dot2], 'Marker', '.', 'MarkerSize', 20)
set(dot1, 'Color', 'b')
set(dot2, 'Color', 'g')
axis([-1.5, 1.5, -1.5, 1.5])
for i = 1:length(t)
set(dot1, 'XData', x(i), 'YData', y(i))
set(dot2, 'XData', 1.5 * x(i), 'YData', 1.5 * y(i))
drawnow
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment