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 02-Aug-2009 23:24:02
% 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
msgbox('MATLAB编程答疑,请加QQ: 993878382','MATLAB答疑','help')
web http://993878382.qzone.qq.com -browser
global flg mark rgb graph;
flg=0; %f初始鼠标没有按下
graph='点线';
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 x0 y0 x y rect graph;
flg=1;
set(handles.pushbutton2,'enable','on');
set(handles.pushbutton3,'enable','on');
currPt = get(gca, 'CurrentPoint');
x = currPt(1,1);
y = currPt(1,2);
switch(graph)
case '点线'
line(x,y, 'marker', mark,'color',rgb);
otherwise
line(x,y,'LineStyle',mark,'color',rgb);
end
x0=x;y0=y;
set(handles.edit1,'string',num2str(x));
set(handles.edit2,'string',num2str(y));
set(handles.text3,'string','Mouse down!');
% --- 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 x0 y0 x y rect graph h;
if flg
switch(graph)
case '点线'
currPt=get(gca, 'CurrentPoint');
x=currPt(1,1);
y=currPt(1,2);
line(x,y, 'marker', mark,'color',rgb);
case '线形'
x0=x;y0=y;
currPt=get(gca, 'CurrentPoint');
x=currPt(1,1);
y=currPt(1,2);
line([x0 x], [y0,y],'LineStyle',mark,'color',rgb);
case '矩形'
currPt=get(gca, 'CurrentPoint');
x=currPt(1,1);
y=currPt(1,2);
if x~=x0
if ~isempty(h)
set(h,'Visible','off')
end
rect=[min([x0,x]),min([y0,y]),abs(x-x0),abs(y-y0)];
if rect(3)*rect(4)~=0
h=rectangle('Position',rect,'LineStyle',':');
end
end
case '椭圆'
currPt=get(gca, 'CurrentPoint');
x=currPt(1,1);
y=currPt(1,2);
if x~=x0
if ~isempty(h)
set(h,'Visible','off')
end
rect=[min([x0,x]),min([y0,y]),abs(x-x0),abs(y-y0)];
if rect(3)*rect(4)~=0
h=rectangle('Position',rect,'Curvature',[1,1],'LineStyle',':');
end
end
end
set(handles.edit1,'string',num2str(x));
set(handles.edit2,'string',num2str(y));
set(handles.text3,'string','Mouse is moving!');
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 mark h graph rect;
flg=0;
switch(graph)
case '矩形'
set(h,'Visible','off');h=[];
if rect(3)*rect(4)~=0
rectangle('Position',rect,'edgecolor',rgb,'LineStyle',mark)
end
case '椭圆'
set(h,'Visible','off');h=[];
if rect(3)*rect(4)~=0
rectangle('Position',rect,'Curvature',[1,1],'edgecolor',rgb,'LineStyle',mark)
end
end
set(handles.text3,'string','Mouse up!');
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
function edit2_Callback(hObject, eventdata, handles)
% hObject handle to edit2 (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 edit2
没有合适的资源?快使用搜索试试~ 我知道了~
MATLAB GUI实现动态画图曲线的源程序代码.zip
共2个文件
m:1个
fig:1个
需积分: 2 0 下载量 108 浏览量
2024-05-27
16:39:48
上传
评论
收藏 8KB ZIP 举报
温馨提示
代码实现了一个交互式的GUI(图形用户界面),用于绘制简单的图形,如点线、直线、矩形和椭圆。用户可以通过鼠标在界面上绘制这些图形,界面提供了多种工具和选项来定制图形的样式和颜色。界面还包含多个控件,如按钮、弹出菜单和文本框,用于控制图形绘制和显示当前鼠标坐标。程序启动时,界面会居中显示,用户可以选择不同的绘图模式(点线、直线、矩形、椭圆)和线型(实线、虚线等)以及颜色(红、绿、蓝、黑)。绘制的图形可以保存为图像文件,用户还可以清除绘图区域或关闭界面。此GUI程序使用了MATLAB的GUIDE工具来设计界面和处理用户交互,适合用于教学或简单的图形绘制任务。
资源推荐
资源详情
资源评论
收起资源包目录
MATLAB GUI实现动态画图曲线的源程序代码.zip (2个子文件)
MATLAB GUI实现动态画图曲线的源程序代码
net1.m 15KB
net1.fig 5KB
共 2 条
- 1
资源评论
AICurator
- 粉丝: 6071
- 资源: 101
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功