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