function mouse(action)
switch action
case 'start'
set(gcbf,'windowbuttondownfcn','mouse draw');
case 'draw'
%当光标移动时 执行'move'的操作
set(gcbf,'windowbuttonmotionfcn','mouse move');
%当光标移动时 执行'stop'的操作
set(gcbf,'windowbuttonupfcn','mouse stop');
case 'move'
%获得当前鼠标的坐标
point = get(gca,'CurrentPoint');
%画出X与Y得坐标值
line(point(:,1),point(:,2),'clipping','on',...
'erasemode','background');
case 'stop' %当鼠标键被释放时,不执行任何操作
set(gcbf,'windowbuttondownfcn','');
set(gcbf,'windowbuttonmotionfcn','');
set(gcbf,'windowbuttonupfcn','');
end