Search Contact information
University of Cambridge Home Department of Engineering
University of Cambridge >  Engineering Department >  computing help
next up previous contents
Next: Local Utilities Up: Using Matlab at CUED Previous: Vectorised code

User Interface Controls

uicontrol and uimenu can produce a variety of objects. The example below uses them directly, but guide is easier.

% uidemo
title('A demo of User Interface Facilities');   
uicontrol('Style','Pushbutton', 'Position', [20, 20, 100,30],...
    'Callback','disp(''Pushbutton'')','String','Push me');
uicontrol('Style','Checkbox',  'Position', [20, 60, 100,30],...
    'Callback','disp(''Checkbox'')','String','Push me too');
uicontrol('Style','Popup',  'Position', [20, 100, 100,30],...
    'Callback','disp(''Popup'')','String','first|second|third');
uicontrol('Style','Radiobutton',  'Position', [20, 140, 50,30],...,
    'Callback','disp(''Radio'')','Min',0,'Max',3, 'Value',3, ...
    'HorizontalAlignment','left', 'String','first|second|third'); 
uicontrol('Style','Slider', 'Position', [20, 180, 100,30],...,
    'Callback','disp(''Slider'')','Max',100,'Min',10,'Value',50);
uicontrol('Style','Edit',  'Position', [20, 220, 100,30],...,
    'Callback','disp(''Edit'')','String','Change me');


top1 = uimenu('Label','Calculator');
uimenu(top1,'Label','add','Callback','disp(''add'')');
uimenu(top1,'Label','subtract','Callback','disp(''subtract'')');
uimenu(top1,'Label','multiply','Callback','disp(''multiply'')');
uimenu(top1,'Label','divide','Callback','disp(''divide'')');
top2 = uimenu('Label','Roots');
uimenu(top2,'Label','square','Callback','disp(''square'')');
uimenu(top2,'Label','cube','Callback','disp(''cube'')');

Each graphical object can have a 'callback' (a routine that's called when the object is clicked-on, etc). Type sigdemo1 to see an example.



© Cambridge University Engineering Dept
Information provided by Tim Love
2006-07-24