MATLAB: Animate a rectangle, for loop used

for loopgetframemovie

Hello! The code below takes a large matrix (x) and shows 'o' moving up and down on a plot. I would like to change the 'o' into a rectangle moving in the same way, hanging by a string. How would I do this?
for i = 1:125
plot(x(i),'o')
axis([0 5 -5 5])
y(i) = getframe
end
movie(y,25,25)

Best Answer

Use the rectangle() function. Get it's handle so you can delete the old one when you want to place a new one.
Related Question