您需要读取下拉列表的值,并使用该值来评估应该显示哪个面板。首先隐藏所有面板,然后只显示感兴趣的面板。我的
DropdownValueChanged
函数如下所示。
% Value changed function: DropDown
function DropDownValueChanged(app, event)
value = app.DropDown.Value;
% Hide all the panels
app.Panel1.Visible = 'off';
app.Panel2.Visible = 'off';
app.Panel3.Visible = 'off';
%If Panel 1 is selected, show panel 1
if strcmp(value,'Panel 1')
app.Panel1.Visible = 'on';
elseif strcmp(value,'Panel 2')
app.Panel2.Visible = 'on';
elseif strcmp(value,'Panel 3')
app.Panel3.Visible = 'on';
end
end
我在
startupFcn
隐藏除第一个面板以外的所有面板。
% Code that executes after component creation
function startupFcn(app)
app.Panel1.Visible = 'on';
app.Panel2.Visible = 'off';
app.Panel3.Visible = 'off';
end