一、简介
基于matlab鼠标画图
二、源代码
function varargout = net1(varargin)
% NET1 M-file for net1.fig
% NET1, by itself, creates a new NET1 or raises the existing
% singleton*.
%
% H = NET1 returns the handle to a new NET1 or the handle to
% the existing singleton*.
%
% NET1('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in NET1.M with the given input arguments.
%
% NET1('Property','Value',...) creates a new NET1 or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before net1_OpeningFunction gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to net1_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Last Modified by GUIDE v2.5 18-Jul-2009 20:12:17
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @net1_OpeningFcn, ...
'gui_OutputFcn', @net1_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before net1 is made visible.
function net1_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to net1 (see VARARGIN)
% Choose default command line output for net1
handles.output = hObject;
movegui(gcf,'center');
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes net1 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = net1_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
% --- Executes on mouse press over figure background, over a disabled or
% --- inactive control, or over an axes background.
% --- Executes during object creation, after setting all properties.
function figure1_CreateFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
global flg mark rgb;
flg=0; %f初始鼠标没有按下
mark='.';
rgb=[1,0,0];
function figure1_WindowButtonDownFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global flg mark rgb;
flg=1;
currPt = get(gca, 'CurrentPoint');
x = currPt(1,1);
y = currPt(1,2);
line(x, y, 'marker', mark,'color',rgb);
set(handles.edit1,'string',num2str(x));
set(handles.edit2,'string',num2str(y));
set(handles.text3,'string','Mouse down!');
set(handles.edit1,'foregroundcolor',rgb);
set(handles.edit2,'foregroundcolor',rgb);
set(handles.text3,'foregroundcolor',rgb);
% --- Executes on mouse motion over figure - except title and menu.
function figure1_WindowButtonMotionFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global flg mark rgb;
if flg
currPt = get(gca, 'CurrentPoint');
x = currPt(1,1);
y = currPt(1,2);
line(x, y, 'marker', mark,'color',rgb);
set(handles.edit1,'string',num2str(x));
set(handles.edit2,'string',num2str(y));
set(handles.text3,'string','Mouse is moving!');
set(handles.edit1,'foregroundcolor',rgb);
set(handles.edit2,'foregroundcolor',rgb);
set(handles.text3,'foregroundcolor',rgb);
end
function figure1_WindowButtonUpFcn(hObject, eventdata, handles)
% hObject handle to figure1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global flg rgb;
flg=0;
set(handles.text3,'string','Mouse up!');
set(handles.edit1,'foregroundcolor',rgb);
set(handles.edit2,'foregroundcolor',rgb);
set(handles.text3,'foregroundcolor',rgb);
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'), get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end
三、运行结果
四、备注
完整代码或者代写添加QQ 1564658423
往期回顾>>>>>>
【信号处理】基于matlab HMM的睡眠状态检测【含Matlab源码 050期】
【信号处理】基于matlab CDR噪声和混响抑制【含Matlab源码 051期】
【信号处理】基于matlab最小二乘法解决稀疏信号恢复问题【含Matlab源码 052期】
【信号处理】基于matlab小波变换的音频水印嵌入提取【含Matlab源码 053期】
【信号处理】基于matlab ICA算法信号分离【含Matlab源码 054期】
【信号处理】基于matlab GUI界面的脉搏信号之脉率存档【含Matlab源码 237期】
【信号处理】基于matlab GUI界面的虚拟信号发生器(各种波形)【含Matlab源码 271期】
【信号处理】基于matlab GUI界面信号发生器之电子琴【含Matlab源码 272期】
【信号处理】基于matlab的数字电子琴设计与实现【含Matlab源码 273期】
【雷达通信】基于matlab的雷达数字信号处理【含Matlab源码 281期】
【雷达通信】基于matlab线性调频(LFM)脉冲压缩雷达仿真【含Matlab源码 283期】
【雷达通信】基于mtatlab距离多普勒(RD)、CS、RM算法的机载雷达成像【含Matlab源码 284期】
【雷达通信】《现代雷达系统分析与设计》大作业【含Matlab源码 285期】
【信号处理】基于matlab GUI语音信号综合处理平台【含Matlab源码 290期】
【信号处理】基于matlab GUI语音信号采集【含Matlab源码 291期】
【信号处理】基于matlab GUI语音幅度调制【含Matlab源码 292期】
【信号处理】基于matlab GUI语音合成【含Matlab源码 293期】
【信号处理】基于matlab GUI语音基频识别【含Matlab源码 294期】
【信号处理】基于matlab GUI语音信号加密解密【含Matlab源码 295期】
【信号处理】基于matlab小波变换的语音增强【含Matlab源码 296期】
【信号处理】基于matlab GUI语音傅立叶变换降噪混频【含Matlab源码 297期】
【信号处理】基于matlab GUI维纳滤波之语音增强【含Matlab源码 298期】
【音频处理】基于matlab GUI语音信号处理2【含Matlab源码 299期】
【雷达通信】基于matlab GUI雷达定位【含Matlab源码 302期】
【雷达通信】基于matlab GUI雷达脉冲压缩【含Matlab源码 303期】
【雷达通信】基于matlab GUI雷达定位模拟【含Matlab源码 304期】
【雷达通信】基于matlab SVM识别雷达数据【含Matlab源码 305期】## 标题
【边缘检测】基于matlab插值法亚像素边缘检测【含Matlab源码 306期】
【模式识别】基于matlab GUI贝叶斯最小错误率手写数字识别【含Matlab源码 308期】
【模式识别】基于matlab PCA手写数字识别【含Matlab源码 309期】
【模式识别】基于matlab 特征匹配的英文印刷字符识别【含Matlab源码 310期】
【模式识别】基于matlab知识库的手写体数字识别【含Matlab源码 311期】
【模式识别】基于matlab之银行卡数字识别【含Matlab源码 312期】
【图像识别】基于matlab表情检测【含Matlab源码 317期】
【图像检测】基于matlab LSD直线检测【含Matlab源码 318期】
【图像融合】红外与可见光的融合与配准算法【含Matlab源码 319期】
【图像识别】基于matlab帧差法跌倒检测【含Matlab源码 320期】
【图像识别】基于matlab组合BCOSFIRE过滤器进行墙体裂缝识别【含Matlab源码 321期】
【模式识别】基于matlab中值滤波和二值化的跌倒检测【含Matlab源码 344期】
【图像隐写】基于matlab DCT的图像隐写【含Matlab源码 365期】
【图像隐写】基于matlab LSB的图像隐写提取【含Matlab源码 366期】
【图像隐写】基于matlab高斯模型的JPEG图像隐写【含Matlab源码 367期】
【图像隐写】基于matlab图像自适应隐写算法wow【含Matlab源码 368期】
【模式识别】基于matlab GUI SVM和PCA的人脸识别【含Matlab源码 369期】
【视频识别】基于matlab轨迹方法行为识别【含Matlab源码 375期】
【模式识别】基于matlab GUI HSV和RGB模型水果分类【含Matlab源码 380期】
【图像处理】基于matlab GUI数字图像处理平台【含Matlab源码 381期】
【图像分割】基于matlab的视网膜图像分割【含Matlab源码 382期】
【模式识别】基于matlab k-means聚类的手势识别【含Matlab源码 386期】
【图像处理】基于Hough变换的人眼虹膜定位【含Matlab源码 387期】
【图像处理】基于matlab Kalman滤波的目标跟踪【含Matlab源码 388期】
【图像分割】基于matlab GAC水平集方法实现图像分割【含Matlab源码 389期】
【图像分割】基于matlab 分水岭算法的图像分割【含Matlab源码 390期】
【图像去噪】基于小波变换的图像去噪【含Matlab源码 391期】
【图像融合】基于matlab小波变换的图像融合【含Matlab源码 392期】
【图像识别】基于matlab图像识别物体计数【含Matlab源码 393期】
【图像增强】基于matlab模糊集的图像增强【含Matlab源码 394期】
【图像检索】基于matlab GUI综合特征的图像检索【含Matlab源码 395期】
【图像处理】基于matlab 图像RGB三色的合成、分离【含Matlab源码 401期】