获取当前鼠标按键的坐标值,左键输出当前点,右键则删除上一个按键值,中间键退出
clear,close all, clc &
x = 1:0.1:10; &
y = 20*sin(pi/2*x); &
plot(x,y); &
points = get_mouse_point() &
-----------------------------------------------------
function points = get_mouse_point() &
% Author:shizhixin & & & &&
% Email: & & & &&
% Blog:http://blog.csdn.net/shizhixin & & & &&
% Date: & &&
% Function:获取当前鼠标按键的坐标值,左键输出当前点,右键则删除上一个按键值,中间键退出 &
% Note:%注意不能按键太快,否则认为是双击会导致出错 &
flag=1;%(1=左键,2=中,3=右) &
points = []; &
while flag == 1 &
& & [x,y,flag] = ginput(1);%获取当前按键的坐标及按键值 &
& & if flag == 1 %如果为左键,用红色画当前点,并且保存当前点的值进入矩阵 &
& & & & plot(x, y, 'r*'); &
& & & & points = [[x, y]]; &
& & & & disp 'save current point'; &
& & elseif flag == 3 %如果为右键,矩阵中有值的情况则为删除操作,删除上一个点,在图中标为品红色 &
& & & & if ~isempty(points) &
& & & & & & plot(points(end,1),points(end,2),'m*'); &
& & & & & & points = points(1:end-1,:); &
& & & & & & disp 'delete'; &
& & & & end &
& & & & flag = 1; &
& & else%鼠标中间键为退出操作 &
& & & & disp 'end' &
(window.slotbydup=window.slotbydup || []).push({
id: '2467140',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467141',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467142',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467143',
container: s,
size: '1000,90',
display: 'inlay-fix'
(window.slotbydup=window.slotbydup || []).push({
id: '2467148',
container: s,
size: '1000,90',
display: 'inlay-fix'可不可以吧苹果手机中间那个按键关了不使用_百度知道