- hf=figure('color',[0,1,1],'position',[100 200 400 200],...
- 'name','数字转换','numberTitle','off','menubar','none');
- uicontrol(hf,'style','Text','Units','normalized',...
- 'position',[0.05 0.8 0.45 0.1],'horizontal','center',...
- 'string','输入筐','back',[0 1 1]);
- uicontrol(hf,'style','Text','Units','normalized',...
- 'position',[0.5 0.8 0.45 0.1],'horizontal','center',...
- 'string','输出筐','back',[0 1 1]);
- uicontrol(hf,'style','Frame','position',[0.04 0.33 0.45 0.45],...
- 'Units','normalized','back',[1 1 0]);
- uicontrol(hf,'style','Text','position',[0.05 0.6 0.25 0.1],...
- 'Units','normalized','horizontal','center',...
- 'string','十进制','back',[1 1 0]);
- uicontrol(hf,'style','Text','position',[0.05 0.4 0.25 0.1],...
- 'Units','normalized','horizontal','center',...
- 'string','2和16进制','back',[1 1 0]);
- he1=uicontrol(hf,'style','Edit','position',[0.25,0.6,0.2,0.1],...
- 'Units','normalized','back',[0 1 0]);
- he2=uicontrol(hf,'style','Edit','position',[0.25,0.4,0.2,0.1],...
- 'Units','normalized','back',[0 1 0]);
- uicontrol(hf,'style','Frame','position',[0.52 033 0.45 0.45],...
- 'Units','normalized','back',[1 1 0]);
- ht=uicontrol(hf,'style','Text','position',[0.6 0.5 0.3 0.1],...
- 'horizontal','center','Units','normalized','back',[0 1 0]);
- COMM=['n=str2num(get(he1,"string"));','b=str2num(get(he2,"string"));',...
- 'dec=trdec(n,b);','set(ht,"string",dec);'];
- uicontrol(hf,'style','push','position',[0.18 0.1 0.2 0.12],...
- 'string','转换','Units','normalized','callback','COMM');
- uicontrol(hf,'style','push','position',[0.65 0.1 0.2 0.12],...
- 'string','退出','Units','normalized','call','close(hf)');
复制代码 |