- h1=uicontrol(gcf,'style','radio',...
- 'string','加',...
- 'value',1,...
- 'position',[20 150 40 20],...
- 'callback',[...
- 'k=1;,',...
- 'set(h1,''value'',1),',...
- 'set(h2,''value'',0),',...
- 'set(h3,''value'',0)']);
- h2=uicontrol(gcf,'style','radio',...
- 'string','减',...
- 'position',[20 110 40 20],...
- 'callback',[...
- 'k=2;,',...
- 'set(h2,''value'',1),',...
- 'set(h1,''value'',0),',...
- 'set(h3,''value'',0)']);
- h3=uicontrol(gcf,'style','radio',...
- 'string','乘',...
- 'position',[20 70 40 20],...
- 'callback',[...
- 'k=3;,',...
- 'set(h3,''value'',1),',...
- 'set(h2,''value'',0),',...
- 'set(h1,''value'',0)']);
- e1=uicontrol(gcf,'style','edit',...
- 'position',[80 150 100 20]);
- e2=uicontrol(gcf,'style','edit',...
- 'position',[80 110 100 20]);
- e3=uicontrol(gcf,'style','edit',...
- 'position',[80 70 100 20]);
- b1=uicontrol(gcf,'style','pushbutton',...
- 'string','运算',...
- 'position',[200 150 80 30],...
- 'callback',[...
- 'x=str2num(get(e1,''string''));,',...
- 'y=str2num(get(e2,''string''));,',...
- 'switch k,',...
- 'case 1,',...
- 'z=x+y;,',...
- 'case 2,',...
- 'z=x-y;,',...
- 'case 3,',...
- 'z=x*y;,',...
- 'end,',...
- 'set(e3,''string'',num2str(z))']);
- b2=uicontrol(gcf,'style','pushbutton',...
- 'string','退出',...
- 'position',[200 100 80 30],...
- 'callback','close');