User`s guide
11 Lay Out a Programmatic GUI
The Style property, pushbutton, specifies the user interface control as a push
button. Because
pushbutton is the default style, you can omit the 'Style'
property from the statement.
The
String property labels the push button as Button 1. The push button
allows only a single line of text. If you specify more than o ne line, only the
first line is shown. If you specify a component width that is too small to
accommodate the s pe cified
String, MATLAB software truncates the string
with an ellipsis.
The Positi
on
property specifies the location and size of the push button. In
this examp
le, the push bu tton is 60 p ix els wide and 40 high . It is positioned
50 pixels
from the left of the figure and 20 pixels from the bottom. This
statemen
tassumesthedefaultvalueofthe
Units property, which is pixels.
Add an Im
age to a Push Button. To add an image to a push button, assign
the butt
on’s
CData property an m-by-n-by-3 array of RGB values that defines
atrueco
lor image. For example, the array
img defines 16-by-64 truecolor
image us
ing random values between 0 and 1 (generated by
rand).
img(:,:,1) = rand(16,64);
img(:,:,2) = rand(16,64);
img(:,:,3) = rand(16,64);
pbh = uicontrol(fh,'Style','pus hbutton',...
'Position',[50 20 100 45],...
'CData',img);
11-26