我这有一个例子,你可以参考一下。<br>主程序这样编:<br>clf;<br>set(gcf,'unit','normalized','position',[0.2,0.3,0.55,0.30]);<br>set(gcf,'menubar','none','name','图形演示','numbertitle','off');<br>axes('position',[0.05,0.15,0.55,0.7]);<br>uicontrol(gcf,'style','text','unit','normalized',...<br> 'posi',[0.63,0.85,0.2,0.1],'string',...<br> '输入绘图命令','horizontal','center');<br>hedit=uicontrol(gcf,'style','edit','unit','normalized',...<br> 'position',[0.63,0.15,0.2,0.68],...<br> 'max',2);<br>hpopup=uicontrol(gcf,'style','popup','unit','normalized',...<br> 'posi',[0.85,0.8,0.15,0.15],'string',...<br> 'spring|summer|autumn|winter','call',...<br> 'comm(hedit,hpopup,hlist)');<br>hlist=uicontrol(gcf,'style','list','unit','normalized',...<br> 'posi',[0.85,0.55,0.15,0.25],'string',...<br> 'grid on|grid off|box on|box off','call',...<br> 'comm(hedit,hpopup,hlist)');<br>hpush1=uicontrol(gcf,'style','push','unit','normalized',...<br> 'posi',[0.85,0.35,0.15,0.15],'string',...<br> '绘图','call','comm(hedit,hpopup,hlist)');<br>uicontrol(gcf,'style','push','unit','normalized',...<br> 'posi',[0.85,0.15,0.15,0.15],'string','关闭','call','close all');<br><br><br>然后再建一个名为comm(hedit,hpopup,hlist)的子程序:<br>function comm(hedit,hpopup,hlist)<br>com=get(hedit,'string');<br>n1=get(hpopup,'value');<br>n2=get(hlist,'value');<br>if ~isempty(com)<br> eval(com');<br> chpop={'spring','summer','autumn','winter'};<br> chlist={'grid on','grid off','box on','box off'};<br> colormap(eval(chpop{1}));<br> eval(chlist{n2});<br>end<br>这样就差不多了。你可以试一下的。<br>以后大家要互相学习哦!!![em31][em25]
[此贴子已经被作者于2006-5-18 15:28:38编辑过]
|