MATLAB Creating Graphical User Interfaces

(ff) #1
check box, MATLAB sets Value to Max when the user checks the box and to Min when
the user unchecks it.

The Position property specifies the location and size of the check box. In this example,
the check box is 130 pixels wide and 20 high. It is positioned 30 pixels from the left of the
figure and 20 pixels from the bottom.

Slider

This code creates a slider:

f = figure;
s = uicontrol(f,'Style','slider',...
'Min',0,'Max',100,'Value',25,...
'SliderStep',[0.05 0.2],...
'Position',[30 20 150 30]);

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','slider' specifies the uicontrol to be a
slider.

'Min',0 and 'Max',100 specify the range of the slider to be [0, 100]. The Min property
must be less than Max.

'Value',25 sets the default slider position to 25. The number you specify for this
property must be within the range, [Min, Max].

9 Lay Out a Programmatic UI

Free download pdf