0

I've made a popup-menu in Matlab using uicontrol, instead of using GUIDE. Here is my code:

figure; 
String = sprintf( '%d#', 1:5);
String(end) = [];
CString=regexp(String , '#' , 'split');
uicontrol('style','popupmenu' , ...
          'String' , CString  , ...
          'Position' , [100,400,100,24]);

But I don't know how can I put a subject for the popup-menu.

If anyone knows I'll appreciate for your help.

Thank You in Advance

4

2 回答 2

0

首先,设置一个图形句柄:

h = figure;

然后,设置窗口的名称:

set(h,'Name','This is my title text');
于 2013-06-13T17:02:28.947 回答
0

您需要添加另一个 ui 对象,可能text或在弹出菜单edit旁边:

(我个人比较喜欢edit,因为它看起来更好)

txt_obj = uicontrol(...
    'Style','edit',...
    'HorizontalAlignment','right',...
    'String', 'Something',...
    'Position' , [0,400,100,24],...
    'BackgroundColor', [.9 .9 .9],...
    'Enable','inactive');

我鼓励您使用标准化单位以简化编码(实际上是定位!)。有关更多信息,请参阅uicontrol 对象Positioning Figures(具有相同的定位概念)的 position 属性。

于 2013-06-13T17:20:30.917 回答