matlab中popupmenu怎么实现数值读取啊
我想从popupmenu中的菜单里得到一个值,然后在另一个方框中显示。为什么get函数出错,程序错在哪里呢?functiondispyear=[2011201220132...
我想从popupmenu中的菜单里得到一个值,然后在另一个方框中显示。为什么get函数出错,程序错在哪里呢?
function disp
year=[2011 2012 2013 2014 ];
month=[1 2 3 4 5 6 7 8 9 10 11 12];
day=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
f=figure('visible','off','position',[100,100,600,400],'color','g');
hyear1=uicontrol('Style','popupmenu','String','2011|2012|2013|2014','Position',[100,250,100,80]);
hyear2=uicontrol('Style','text','String','年','Position',[210,310,40,25]);
hmonth1=uicontrol('Style','popupmenu','String','1|2|3|4|5|6|7|8|9|10|11|12','Position',[260,250,100,80]);
hmonth2=uicontrol('Style','text','String','月','Position',[370,310,40,25]);
hbutton1=uicontrol('Style','pushbutton','String','查一下','position',[200,200,100,25],'Callback',{@display});
hstart1=uicontrol('Style','text','String','时间','position',[0,350,150,25],'BackgroundColor','m','FontSize',16);
hshow=uicontrol('Style','text','String','请点击左面按钮查询','Position',[300,200,100,25]);
movegui(f,'center');
set(f,'visible','on');
%%function huidiao(source,event)
%end
global hyear1 hshow
function display(src,event)
a=get(hyear1,'value')
switch a
case 1
set(hshow,'String','今年是2012年');
case 2012
set(hshow,'String','进年是2012年');
case 3
set(hshow,'String','今年是2013年');
case 4
set(hshow,'String','今年是2014年');
end
end
end 展开
function disp
year=[2011 2012 2013 2014 ];
month=[1 2 3 4 5 6 7 8 9 10 11 12];
day=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31];
f=figure('visible','off','position',[100,100,600,400],'color','g');
hyear1=uicontrol('Style','popupmenu','String','2011|2012|2013|2014','Position',[100,250,100,80]);
hyear2=uicontrol('Style','text','String','年','Position',[210,310,40,25]);
hmonth1=uicontrol('Style','popupmenu','String','1|2|3|4|5|6|7|8|9|10|11|12','Position',[260,250,100,80]);
hmonth2=uicontrol('Style','text','String','月','Position',[370,310,40,25]);
hbutton1=uicontrol('Style','pushbutton','String','查一下','position',[200,200,100,25],'Callback',{@display});
hstart1=uicontrol('Style','text','String','时间','position',[0,350,150,25],'BackgroundColor','m','FontSize',16);
hshow=uicontrol('Style','text','String','请点击左面按钮查询','Position',[300,200,100,25]);
movegui(f,'center');
set(f,'visible','on');
%%function huidiao(source,event)
%end
global hyear1 hshow
function display(src,event)
a=get(hyear1,'value')
switch a
case 1
set(hshow,'String','今年是2012年');
case 2012
set(hshow,'String','进年是2012年');
case 3
set(hshow,'String','今年是2013年');
case 4
set(hshow,'String','今年是2014年');
end
end
end 展开
ZESTRON
2024-09-04 广告
2024-09-04 广告
在Dr. O.K. Wack Chemie GmbH,我们高度重视ZESTRON的表界面分析技术。该技术通过深入研究材料表面与界面的性质,为提升产品质量与可靠性提供了有力支持。ZESTRON的表界面分析不仅涵盖了相变化、化学反应、吸附与解吸...
点击进入详情页
本回答由ZESTRON提供
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询