数学建模社区-数学中国

标题: 【奠基经典】MATLAB实用程序案例之弹出式菜单 [打印本页]

作者: 青年梦想家    时间: 2015-7-27 23:05
标题: 【奠基经典】MATLAB实用程序案例之弹出式菜单






弹出式菜单

实例:

h0=figure('toolbar','none',...

'position',[200 150 450 250],...

'name','实例36');

x=0:0.5:2*pi;

y=sin(x);

h=plot(x,y);

grid on

hm=uicontrol(gcf,'style','popupmenu',...

'string',...

'sin(x)|cos(x)|sin(x)+cos(x)|exp(-sin(x))',...

'position',[250 20 50 20]);

set(hm,'value',1)

huidiao=[...

'v=get(hm,''value'');,',...

'switch v,',...

'case 1,',...

'delete(h),',...

'y=sin(x);,',...

'h=plot(x,y);,',...

'grid on,',...

'case 2,',...

'delete(h),',...

'y=cos(x);,',...

'h=plot(x,y);,',...

'grid on,',...

'case 3,',...

'delete(h),',...

'y=sin(x)+cos(x);,',...

'h=plot(x,y);,',...

'grid on,',...

'case 4,',...

'delete(h),',...

'y=exp(-sin(x));,',...

'h=plot(x,y);,',...

'grid on,',...

'end'];

set(hm,'callback',huidiao)

set(gca,'position',[0.2 0.2 0.6 0.6])

title('弹出式菜单的使用')

hold on



关于本帖内容欢迎大家踊跃讨论,与在下交流!






欢迎光临 数学建模社区-数学中国 (http://www.madio.net/) Powered by Discuz! X2.5