使用matlab实现类似windows系统中的画图小软件,带GUI界面
2023-09-14 09:06:08 时间
目录
1.仿真效果预览
matlab2022a仿真结果如下:
2.MATLAB核心程序
................................................................
% --- 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
A147
.....................................
3.完整MATLAB
V
相关文章
- windows环境搭建web服务器(IIS)
- matlab怎么对语音信号处理,语音信号处理MATLAB程序
- Windows/Mac系统下常用的SSH工具软件
- matlab中如何求插值点,MATLAB插值「建议收藏」
- matlab interp1db,matlab – Matlab interp1图出现数据偏移 – 堆栈内存溢出
- Windows查看端口占用情况_windows关闭端口命令
- Windows系统封装学习
- bp神经网络及matlab实现_bp神经网络应用实例Matlab
- butterworth matlab,Matlab实现Butterworth滤波器
- WINDOWS下安装系统_在Windows环境下
- Pywinauto之Windows UI自动化4
- 【错误记录】Windows 系统 bat 脚本报错 ( 使用 pause 拦截窗口自动关闭 | 方便查看错误 )
- 和 windowsC语言在连接Linux与Windows之间的作用(c连接linux)
- 使用Windows连接Linux:强大的工具(windows连接linux工具)
- windows激活Windows:Linux下的秘诀(linux激活)
- 在Windows下安装Python开发环境(图文版)
- windows把Exsi、Linux和Windows兼容:实现三端互联的技术之旅(exsilinux)
- windows比较:Linux和Windows的优势与劣势(linuxvss)
- 微软确定将推Windows 11 LTSC版本:支持5年时间
- 服务在Windows系统上启动Redis服务(windows启动redis)
- 微软承认更新导致 Windows 7 壁纸黑屏,普通用户无缘修复补丁
- “Linux轻松与Windows双启:引导快速添加方法”(linux添加windows引导)
- Windows无法启动MySQL服务:解决方案.(windows无法启动mysql服务)
- 比较Linux系统与Windows系统的异同(linux系统和windows系统的区别)
- Linux将文件传输到Windows系统中(linux传文件到windows)
- Linux与Windows的差异:显而易见的对比(linux与windows的区别)
- Windows命令行连接MySQL数据库(cmd中链接mysql)
- 放在windows上Windows上安装Redis的步骤(如何把redis的exe)
- Windows下搭建PHP开发环境(Apache+PHP+MySQL)
- Windows系统下安装和部署Egret的开发环境