Matlab r2014b 获取 GUI 中哪个选项卡处于活动状态的信息

Matlab r2014b get info which tab is active in GUI

我在新的 Matlab R2014b 版本中有一个代码,在 GUI 中带有选项卡:

hTabGroup = uitabgroup('units','pixels','position',[22 245 900 435])`   
tabs(1) = uitab(hTabGroup, 'title','Curve 1'); 
tabs(2) = uitab(hTabGroup, 'title','Curve 2'); 

我如何在代码中询问哪个选项卡在 GUI 中处于活动状态?

参见SelectedTab property of the uitabgroup

SelectedTab — Currently selected tab uitab object This property is read only.

Currently selected tab, specified as a uitab object.

Use this property to determine the currently selected uitab within a uitabgroup. You can also use this property to initialize the GUI with a default uitab selection.

The default value of the SelectedTab property is the first uitab that you add to the uitabgroup.

提取标题,使用您的示例代码并选择 'Curve 2':

hTabGroup = uitabgroup('units','pixels','position',[22 245 900 435]);
tabs(1) = uitab(hTabGroup, 'title','Curve 1'); 
tabs(2) = uitab(hTabGroup, 'title','Curve 2'); 
mytab = hTabGroup.SelectedTab.Title

mytab =

Curve 2