h0=figure('toolbar','none',...
'position',[198 56 408 468],...
'name','实例49');
h1=axes('parent',h0,...
'position',[0.15 0.45 0.7 0.5],...
'visible','on');
x=0:0.1:2*pi;
y=sin(x);
plot(x,y);
xlabel('X');
ylabel('Y');
title('坐标轴范围的改变');
h=get(gca,'xlim');
k=get(gca,'ylim');
e1=uicontrol('parent',h0,...
'style','edit',...
'string',eval(num2str(h(1))),...
'horizontalalignment','right',...
'position',[80 120 100 20]);
t1=uicontrol('parent',h0,...
'style','text',...
'string','X轴最小值',...
'position',[100 145 80 20]);
e2=uicontrol('parent',h0,...
'style','edit',...
'string',eval(num2str(h(2))),...
'horizontalalignment','right',...
'position',[80 60 100 20]);
t2=uicontrol('parent',h0,...
'style','text',...
'string','X轴最大值',...
'position',[100 85 80 20]);
e3=uicontrol('parent',h0,...
'style','edit',...
'string',eval(num2str(k(1))),...
'horizontalalignment','right',...
'position',[250 120 100 20]);
t3=uicontrol('parent',h0,...
'style','text',...
'string','Y轴最小值',...
'position',[270 145 80 20]);
e4=uicontrol('parent',h0,...
'style','edit',...
'string',eval(num2str(k(2))),...
'horizontalalignment','right',...
'position',[250 60 100 20]);
t4=uicontrol('parent',h0,...
'style','text',...
'string','X轴最小值',...
'position',[270 85 80 20]);
p1=uicontrol('parent',h0,...
'style','pushbutton',...
'string','设置',...
'position',[105 10 50 30],...
'callback',[...
'a=str2num(get(e1,''string''));,',...
'b=str2num(get(e2,''string''));,',...
'c=str2num(get(e3,''string''));,',...
'd=str2num(get(e4,''string''));,',...
'axis([a b c d]),',...
'drawnow']);
p2=uicontrol('parent',h0,...
'style','pushbutton',...
'string','关闭',...
'position',[275 10 50 30],...
'callback','close');
实例50:绘制不同函数曲线的用户界面
h0=figure('toolbar','none',...
'position',[198 56 408 468],...
'name','实例50');
h1=axes('parent',h0,...
'position',[0.29 0.45 0.7 0.5],...
'visible','on');
f=uicontrol('parent',h0,...
'style','frame',...
'position',[5 50 90 400]);
p1=uicontrol('parent',h0,...
'style','pushbutton',...
'position',[150 100 60 40],...
'string','绘图',...
'callback',[...
'm=str2num(get(e1,''string''));,',...
'n=str2num(get(e2,''string''));,',...
'a=get(l1,''value'');,',...
'x=m:0.1:n;',...
'if a==1,',...
'plot(x,sin(x)),',...
'end,',...
'if a==2,',...
'plot(x,cos(x)),',...
'end,',...
'if a==3,',...
'plot(x,exp(x)),',...
'end']);
p2=uicontrol('parent',h0,...
'style','pushbutton',...
'position',[270 100 60 40],...
'string','关闭',...
'callback','close');
l1=uicontrol('parent',h0,...
'style','listbox',...
'position',[10 300 80 80],...
'string','sin(x)|cos(x)|exp(x)',...
'value',1,...
'max',0.5,...
'min',0);
f2=uicontrol('parent',h0,...
'style','text',...
'string','选择函数',...
'fontsize',10,...
'position',[10 380 80 20]);
r1=uicontrol('style','radio',...
'string','grid on',...
'value',0,...
'position',[10 100 60 20],...
'callback',[...
'grid on,',...
'set(r1,''value'',1);,',...
'set(r2,''value'',0)']);
r2=uicontrol('style','radio',...
'string','grid off',...
'position',[10 80 60 20],...
'value',1,...
'callback',[...
'grid off,',...
'set(r2,''value'',1);,',...
'set(r1,''value'',0)']);
e1=uicontrol('parent',h0,...
'style','edit',...
'string',0,...
'position',[20 210 60 20],...
'horizontalalignment','right');
e2=uicontrol('parent',h0,...
'style','edit',...
'string','3',...
'position',[20 150 60 20],...
'horizontalalignment','right');
t1=uicontrol('parent',h0,...
'style','text',...
'string','X from',...
'fontsize',10,...
'position',[20 230 60 20],...
'horizontalalignment','center');
t2=uicontrol('parent',h0,...
'style','text',...
'string','To',...
'fontsize',10,...
'position',[20 170 60 20],...
'horizontalalignment','center');
matlab坐标轴范围的设定方法
5星 · 超过95%的资源 需积分: 32 166 浏览量
2010-01-21
18:19:49
上传
评论 2
收藏 1KB RAR 举报
sunpshine
- 粉丝: 0
- 资源: 7
最新资源
- Win64OpenSSL-3-3-0.exe
- 课高分程设计-基于C++实现的民航飞行与地图简易管理系统-南京航空航天大学
- 航天器遥测数据故障检测系统python源码+文档说明+数据库(课程设计)
- 北京航空航天大学操作系统课设+ppt+实验报告
- 基于Vue+Echarts实现风力发电机中传感器的数据展示监控可视化系统+源代码+文档说明(高分课程设计)
- 基于单片机的风力发电机转速控制源码
- 基于C++实现的风力发电气动平衡监测系统+源代码+测量数据(高分课程设计)
- 毕业设计- 基于STM32F103C8T6 单片机,物联网技术的太阳能发电装置+源代码+文档说明+架构图+界面截图
- 基于 LSTM(长短期记忆)(即改进的循环神经网络)预测风力发电厂中风力涡轮机产生的功率+源代码+文档说明
- 基于stm32f103+空心杯电机+oled按键+运动算法
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈