0

所以基本上我的 MATLAB 代码中有很多这样的行:

% Hides SelectDateDropDown object.
app.SelectDateDropDown.Enable = false;
app.SelectDateDropDown.Visible = false;
app.SelectDateLabel.Enable = false;
app.SelectDateLabel.Visible = false;

% Hides Previous object.
app.PreviousButton.Enable = false;
app.PreviousButton.Visible = false;

% Hides Next object.
app.NextButton.Enable = false;
app.NextButton.Visible = false;

% Hides UnitsDropDown object.
app.SelectUnitsDropDown.Enable = false;
app.SelectUnitsDropDown.Visible = false;
app.SelectUnitsLabel.Enable = false;
app.SelectUnitsLabel.Visible = false;

...然后类似的线条来显示这些对象等...我试图找出什么是最好的“省线”方法,但没有成功。这些对象有时会有所不同,有时它们没有 Enable 属性,但可以通过 try-catch 块解决。

你有什么想法吗?

感谢您的任何建议。

4

1 回答 1

0

您可以将set函数与句柄数组一起使用:

handles = [app. SelectDateDropDown, app.SelectDateLabel, ... ];
set(handles, 'Enable', false, 'Visible', false);
于 2020-01-19T00:52:42.893 回答