MATLAB Creating Graphical User Interfaces

(ff) #1
The name-value pair arguments, 'Data',magic(5), specifies the table data. In this
case, the data is the 5-by-5 matrix returned by the magic(5) command.

You can adjust the width and height of the table to accommodate the extent of the data.
The uitable’s Position property controls the outer bounds of the table, and the Extent
property indicates the extent of the data. Set the last two values in the Position
property to the corresponding values in the Extent property:

tb.Position(3) = tb.Extent(3);
tb.Position(4) = tb.Extent(4);

You can change several other characteristics of the table by setting certain properties:


  • To control the user’s ability to edit the table cells, set the ColumnEditable property.

  • To make your application respond when the user edits a cell, define a
    CellEditCallback function.

  • To add or change row striping, set the RowStriping property.

  • To specify row and column names, set the RowName and ColumnName properties.

  • To format the data in the table, set the ColumnFormat property.


See Uitable for the entire list of properties.

If you are building an app using GUIDE, you can set many of the uitable properties using
the Table Property Editor. For more information, see “Create a Table” on page 6-49.

Panels


This code creates a panel:

f = figure;
p = uipanel(f,'Title','My Panel',...
'Position',[.25 .1 .5 .8]);

9 Lay Out a Programmatic UI

Free download pdf