Clearing the last plotted image in a for loop.
Show older comments
I want this program (see below), to plot a blue circle travelling in a circular path. The radius of the path is the variable r and the orbital period is the variable T. The problem I'm having is that the previous blue circles aren't deleted. The plot looks like this:

function solsystem(r,T)
bildNr = 0;
for t=linspace(0,10,100)
plot(r.*cos(2/pi-w*t),r.*sin(2/pi-w*t),'bo')
drawPath(r)
plot(0,0,'o','MarkerSize',10,'MarkerEdgeColor','k','MarkerFaceColor','y')
var(r,T)
figure(1),clf;
bildNr = bildNr +1;
film(bildNr)=getframe;
end
function drawPath(r)
beta = linspace(0, 2*pi);
plot(r.*cos(beta),r.*sin(beta),'k');
axis equal;
end
function var(T)
w = 2*pi./T; %vinkelhastighet%
end
end
Accepted Answer
More Answers (0)
Categories
Find more on Annotations in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
