MATLAB Creating Graphical User Interfaces

(ff) #1

lb = uicontrol(f,'Style','listbox',...
'String',{'one','two','three','four'},...
'Max',2,'Min',0,'Value',[1 3],...
'Position',[30 20 130 80]);


If you want no initial selection, set these property values:



  • Set the Max and Min properties such that Max - Min is greater than 1.

  • Set the Value property to an empty matrix [].


If the list box is not large enough to display all list entries, you can set the ListBoxTop
property to the index of the item you want to appear at the top when the component is
created.


Tables


This code creates a table and populates it with the values returned by magic(5).


f = figure;
tb = uitable(f,'Data',magic(5));


The first uitable 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.


Add Components to a Programmatic App
Free download pdf