shg                 %show graph 
clf                 %clear plotting window
n=zeros(21,1);                %index
v=(-1:.1:1)';       %x values
j=1;

set (gcf,'doublebuffer','on')
x=zeros(21,1);
y=zeros(21,1);
h=plot(n,y,'.');
axis([-1 1 -1 1])
axis square
stop=uicontrol('style','toggle','string','stop');

while get(stop,'value')==0
    x=v+cos(2*pi.*v/100-0.1.*n);
    set(h,'xdata',x,'ydata',y);
    drawnow;
    %j=j+.01;
    %n=cos(2*pi*j); 
    n=n+0.01;
end
