MATLAB Creating Graphical User Interfaces

(Barry) #1
Add Components to a Programmatic UI

'String','Indent nested functions.',...
'Value',1,'Position',[30 20 150 20]);


The first uicontrol argument, f, specifies the parent container. In this case, the parent
is a figure, but you can also specify the parent to be any container, such as a panel or
button group. If you have multiple radio buttons, you can manage their selection by
specifying the parent to be a button group. See “Button Groups” on page 10-24 for
more information.


The name-value pair arguments, 'Style','radiobutton' specifies the uicontrol to a
radio button.


'String','Indent nested functions.' specifies a label for the radio button.


'Value',1 selects the radio button by default. Set the Value property to be the value
of the Max property to select the radio button. Set the value to be the value of the Min
property to deselect the radio button. The default values of Max and Min are 1 and 0,
respectively.


'Position',[30 20 150 20] specifies the location and size of the radio button. In
this example, the radio button is 150 pixels wide and 20 high. It is positioned 30 pixels
from the left of the figure and 20 pixels from the bottom.


Toggle Button


This code creates a toggle button:


f = figure;
tb = uicontrol(f,'Style','togglebutton',...
'String','Left/Right Tile',...
'Value',0,'Position',[30 20 100 30]);

Free download pdf