Q: How to input data using the mouse?

Use ginput function:

 x=0;y=0;
 while ~isempty(x)
    [x1,y1]=ginput(1);
    plot([x x1],[y y1],'b.-');
    hold on
    x=x1;y=y1;
end