matlab 绘制不同函数曲线的用户界面

[复制链接]
 楼主| cooldog123pp 发表于 2024-5-25 10:53 | 显示全部楼层 |阅读模式
  1. 绘制不同函数曲线的用户界面

  2. h0=figure('toolbar','none',...
  3.     'position',[198 56 408 468],...
  4.     'name','实例50');
  5. h1=axes('parent',h0,...
  6.     'position',[0.29 0.45 0.7 0.5],...
  7.     'visible','on');
  8. f=uicontrol('parent',h0,...
  9.     'style','frame',...
  10.     'position',[5 50 90 400]);
  11. p1=uicontrol('parent',h0,...
  12.     'style','pushbutton',...
  13.     'position',[150 100 60 40],...
  14.     'string','绘图',...
  15.     'callback',[...
  16.         'm=str2num(get(e1,''string''));,',...
  17.         'n=str2num(get(e2,''string''));,',...
  18.         'a=get(l1,''value'');,',...
  19.         'x=m:0.1:n;',...
  20.         'if a==1,',...
  21.         'plot(x,sin(x)),',...
  22.         'end,',...
  23.         'if a==2,',...
  24.         'plot(x,cos(x)),',...
  25.         'end,',...
  26.         'if a==3,',...
  27.         'plot(x,exp(x)),',...
  28.         'end']);
  29. p2=uicontrol('parent',h0,...
  30.     'style','pushbutton',...
  31.     'position',[270 100 60 40],...
  32.     'string','关闭',...
  33.     'callback','close');
  34. l1=uicontrol('parent',h0,...
  35.     'style','listbox',...
  36.     'position',[10 300 80 80],...
  37.     'string','sin(x)|cos(x)|exp(x)',...
  38.     'value',1,...
  39.     'max',0.5,...
  40.     'min',0);
  41. f2=uicontrol('parent',h0,...
  42.     'style','text',...
  43.     'string','选择函数',...
  44.     'fontsize',10,...
  45.     'position',[10 380 80 20]);
  46. r1=uicontrol('style','radio',...
  47.     'string','grid on',...
  48.     'value',0,...
  49.     'position',[10 100 60 20],...
  50.     'callback',[...
  51.         'grid on,',...
  52.         'set(r1,''value'',1);,',...
  53.         'set(r2,''value'',0)']);
  54. r2=uicontrol('style','radio',...
  55.     'string','grid off',...
  56.     'position',[10 80 60 20],...
  57.     'value',1,...
  58.     'callback',[...
  59.         'grid off,',...
  60.         'set(r2,''value'',1);,',...
  61.         'set(r1,''value'',0)']);
  62. e1=uicontrol('parent',h0,...
  63.     'style','edit',...
  64.     'string',0,...
  65.     'position',[20 210 60 20],...
  66.     'horizontalalignment','right');
  67. e2=uicontrol('parent',h0,...
  68.     'style','edit',...
  69.     'string','3',...
  70.     'position',[20 150 60 20],...
  71.     'horizontalalignment','right');
  72. t1=uicontrol('parent',h0,...
  73.     'style','text',...
  74.     'string','X from',...
  75.     'fontsize',10,...
  76.     'position',[20 230 60 20],...
  77.     'horizontalalignment','center');
  78. t2=uicontrol('parent',h0,...
  79.     'style','text',...
  80.     'string','To',...
  81.     'fontsize',10,...
  82.     'position',[20 170 60 20],...
  83.     'horizontalalignment','center');


您需要登录后才可以回帖 登录 | 注册

本版积分规则

2264

主题

7516

帖子

31

粉丝
快速回复 在线客服 返回列表 返回顶部