'Position',[30 20 100 30] specifies the location and size of the toggle button. In
this example, the toggle button is 100 pixels wide and 30 pixels high. It is positioned 30
pixels from the left of the figure and 20 pixels from the bottom.
NoteYou can also display an icon on a toggle button. See “Displaying an Icon on a Push
Button” on page 9-5 for more information.
Check Box
This code creates a check box:
f = figure;
c = uicontrol(f,'Style','checkbox',...
'String','Display file extension',...
'Value',1,'Position',[30 20 130 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.
The name-value pair arguments, 'Style','checkbox', specify the uicontrol to be a
check box.
The next pair, 'String','Display file extension' puts a text label on the check
box.
The Value property specifies whether the box is checked. Set Value to the value of the
Max property (default is 1 ) to create the component with the box checked. Set Value to
Min (default is 0 ) to leave the box unchecked. Correspondingly, when the user clicks the
Add Components to a Programmatic App