matlab 除法计算器

[复制链接]
 楼主| cooldog123pp 发表于 2024-2-24 21:06 | 显示全部楼层 |阅读模式
  1. h=figure('toolbar','none',...
  2.     'position',[200 150 450 250],...
  3.     'name','实例41');
  4. h1=uicontrol(gcf,'style','edit',...
  5.     'position',[80 200 100 20],...
  6.     'HorizontalAlignment','right',...
  7.     'callback',['m=get(h1,''string'');,',...
  8.         'a=str2num(m);']);
  9. h2=uicontrol(gcf,'style','edit',...
  10.     'HorizontalAlignment','right',...
  11.     'position',[80 150 100 20],...
  12.     'callback',['n=get(h2,''string'');,',...
  13.         'b=str2num(n);']);
  14. h3=uicontrol(gcf,'style','text',...
  15.     'string','被除数',...
  16.     'position',[80 230 100 20]);
  17. h4=uicontrol(gcf,'style','edit',...
  18.     'position',[80 50 100 20]);
  19. h5=uicontrol(gcf,'style','pushbutton',...
  20.     'position',[80 100 100 20],...
  21.     'string','=',...
  22.     'callback',[...
  23.         'if b==0,',...
  24.         'h7=errordlg(''除数不能为0!'',''error'',''on'');,',...
  25.         'else,',...
  26.         'k=a/b;,',...
  27.         'c=num2str(k);,',...
  28.         'set(h4,''string'',c),',...
  29.         'end']);
  30. h8=uicontrol(gcf,'style','text',...
  31.     'string','除数',...
  32.     'position',[80 175 100 20]);
  33. h9=uicontrol(gcf,'style','text',...
  34.     'string','商',...
  35.     'position',[80 75 100 20]);


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

本版积分规则

2224

主题

7414

帖子

31

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

2224

主题

7414

帖子

31

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