In the code below, I have a circle moving up and down, with the function y = sin(x) serving as the origin. However, I need to fix this so that the sine equation is used to only calculate the y-position of the circle at each point in time. I do not want the entire sine wave plotted. What would be the best way to do this? I was thinking a list? Any help appreciated!
x = 0:.01:50;
y = sin(x);
px = 10;
py = 0;
img =imread('AvgBscan.tiff');
for i=1:630
imshow(img);
set(gcf,'DoubleBuffer', 'off');
h = patch([0 1 0 1], [0 1 1 0], 'r');
hold on
figure(100);
hold off
py = y(i)
plot(x,y, px, py,'o');
pause(0.05);
drawnow
end