function [xp,yp]=draw_line_unclosed
add_segments=1;
title('right click to end');
while add_segments==1;
    hold on,
    button_pressed=1;
    xp=[];yp=[];
    while button_pressed==1,
        [xtmp, ytmp, button_pressed] = ginput2(1);
        if button_pressed ==1 || button_pressed==3,
            xp=cat(1,xp,xtmp);
            yp=cat(1,yp,ytmp);
            if size(xp,1)>1,
                h=line([xp(size(xp,1));xp(size(xp,1)-1)],[yp(size(yp,1));yp(size(yp,1)-1)]);
            end;
        end;
    end;
    %xp=[xp;xp(1)];yp=[yp;yp(1)];
    h=line(xp,yp);
    set(h,'color',[0 1 0]);
    add_segments=0;    
end;
title('');