This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

uitable

Create table user interface component

Syntax

uit = uitable
uit = uitable(Name,Value)
uit = uitable(parent)
t = uitable(parent,Name,Value)

Description

uit = uitable creates a table user interface component in the current figure and returns the Table UI component object. If there is no figure available, MATLAB® calls the figure function to create one.

uit = uitable(Name,Value) specifies property values of the Table UI component using one or more name-value pair arguments.

example

uit = uitable(parent) creates the table in the specified parent container. The parent container can be a figure created with either the figure or uifigure function, or a child container such as a panel.

example

t = uitable(parent,Name,Value) specifies the parent container and one or more properties values.

Examples

collapse all

Create a Table UI component that displays a 3-by-10 array of random integers. The Data property specifies the values to display, and the Position property specifies the location and size of the table within the figure.

f = figure;
uit = uitable(f,'Data',randi(100,10,3),'Position',[20 20 262 204]);

Table UI components can accommodate a mixture of different data types across the columns.

Create an empty Table UI component.

f = figure;
uit = uitable(f);

Set the Data property to populate the data as a cell array that contains a mixture of different types. Then set the Position property to adjust the location and size of the table to fit the data.

d = {'Male',52,true;'Male',40,true;'Female',25,false};
uit.Data = d;
uit.Position = [20 20 258 78];

Set the ColumnName property to change the column headings to descriptive names. Set the ColumnEditable property to true so that users can edit the data in the UI. When a user changes a value in the UI, the Data property updates to reflect that change.

uit.ColumnName = {'Gender','Age','Authorized'};
uit.ColumnEditable = true;

Starting in R2018a, you can display table array data in a Table UI component. This type of data is supported only when the Table UI component is in a figure created with the uifigure function. App Designer uses this type of figure for creating apps.

Create table array t by calling the readtable function to read data from a file. Select 4 variables and 15 rows from t.

t = readtable('patients.xls');
vars = {'Age','Systolic','Diastolic','Smoker'};
t = t(1:15,vars);

Create a Table UI component, and specify t as the data.

f = uifigure;
uit = uitable(f,'Data',t);

Input Arguments

collapse all

Parent container, specified as a figure created with either the figure or uifigure function, or a child container:

  • Panels, tabs and button groups can be containers in either type of figure.

  • Grid layouts can be containers only in figures created with the uifigure function.

Name-Value Pair Arguments

Example: 'Data',[1 2 3; 4 5 6]

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments as Name1,Value1,...,NameN,ValueN.

You can set Table properties using Name-Value pair arguments.

  • For a list of properties available for GUIDE, or for creating apps with the figure function, see Table Properties for GUIDE.

  • For a list of properties available for App Designer, or for creating apps with the uifigure function, see Table Properties for App Designer.

Output Arguments

collapse all

Table UI component object. Use uit to set properties creating the object.

See Also

Properties

Introduced before R2006a