MATLAB中的popupmenu如何实现
2个回答
2013-05-19
展开全部
好像可以,我给你一个例子,不过是实现图像的选取功能,你可以在编辑窗口中运行,但是实现了功能
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
jb=uicontrol(gcf,'style','popupmenu',...
'string',...
'sin(x)|cos(x)|sin(x)+cos(x)|exp(-sin(x))',...
'position',[250 20 50 20]);
set(jb,'value',1)
huidiao=[...
'v=get(jb,''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(jb,'callback',huidiao)
set(gca,'position',[0.2 0.2 0.6 0.6])
title('弹出式菜单的使用')
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
jb=uicontrol(gcf,'style','popupmenu',...
'string',...
'sin(x)|cos(x)|sin(x)+cos(x)|exp(-sin(x))',...
'position',[250 20 50 20]);
set(jb,'value',1)
huidiao=[...
'v=get(jb,''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(jb,'callback',huidiao)
set(gca,'position',[0.2 0.2 0.6 0.6])
title('弹出式菜单的使用')
2013-05-19
展开全部
首付v
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询