function vectordemo(itrace,visset)
%function vectordemo(itrace,visset)
%itrace: flag to control whether trace of positions of intermediate point
%is shown
% visset: visibility of frame points (optional, default to 'on');

framevis='on';
if nargin>1 framevis=visset; end;

figure;
set(gcf,'doublebuffer','on');

pausedur=1/25;

xinc=1;
yinc=1;
xmax=100;
ylo=10;
yhi=30;

hax=axes;

ylim([0 40]);
xlim([0 xmax]);

xpos=1;
ypos=ylo;

hl1=line('xdata',[xpos;xpos],'ydata',[ylo yhi],'linestyle','none','marker','o','markersize',12,'linewidth',2);
hl2=line('xdata',[xpos],'ydata',ypos,'linestyle','none','marker','x','markersize',12,'linewidth',2);

set(hl1,'visible',framevis);

ifinished=0;
tx=xpos;ty=ypos;
%itrace=1;
while ~ifinished
    xpos=xpos+xinc;
    set(hl1,'xdata',[xpos;xpos]);
    ypos=ypos+yinc;
    if itrace
        tx=[tx;xpos];
        ty=[ty;ypos];
    set(hl2,'xdata',tx,'ydata',ty);
else        
    set(hl2,'xdata',xpos,'ydata',ypos);
end;
drawnow;
    if xpos>=xmax xinc=-xinc; end;
    if xpos<=1 xinc=-xinc; end;
    if ypos>=yhi yinc=-yinc; end;
    if ypos<=ylo yinc=-yinc; end;
    pause(pausedur);
end;
