Create table UI component


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


t = uitable creates a uitable in an existing figure and returns the uitable object, t. If there is no figure available, then MATLAB® creates a new figure to serve as the parent.

t = uitable(Name,Value,...) creates a uitable and specifies one or more uitable property names and corresponding values. Use this syntax to override the default uitable properties.

t = uitable(parent) creates a uitable and designates a specific parent object. The parent argument can be a figure, uipanel, uibuttongroup, or uitab object.

t = uitable(parent,Name,Value,...) creates a uitable with a specific parent and one or more uitable properties.


This example creates a uitable containing three columns of random numbers. The columns in this uitable are 50 pixels wide.

f = figure;
d = gallery('integerdata',100,[10 3],0);
t = uitable(f,'Data',d,'ColumnWidth',{50});

Next, set the width and height of the uitable to match the size of the enclosing rectangle:

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

This example creates a uitable with specific column names and row names:

f = figure('Position',[440 500 461 146]);

% create the data
d = [1 2 3; 4 5 6; 7 8 9];

% Create the column and row names in cell arrays 
cnames = {'X-Data','Y-Data','Z-Data'};
rnames = {'First','Second','Third'};

% Create the uitable
t = uitable(f,'Data',d,...

% Set width and height
t.Position(3) = t.Extent(3);
t.Position(4) = t.Extent(4);

This example creates a table containing different types of data:

  • First two columns are numeric. The first column displays values with up to four decimal places. The second column displays values in currency format.

  • Third column contains check boxes (specified as logical values in the Data array).

  • Fourth column contains pop-up menus, each having two choices: Fixed and Adjustable.

f = figure('Position',[100 100 400 150]);

% Column names and column format
columnname = {'Rate','Amount','Available','Fixed/Adj'};
columnformat = {'numeric','bank','logical',{'Fixed' 'Adjustable'}};

% Define the data
d =    {6.125678  456.3457  true   'Fixed';...
        6.75   510.2342  false  'Adjustable';...   
        7      658.2     false  'Fixed';};

% Create the uitable
t = uitable('Data', d,... 
            'ColumnName', columnname,...
            'ColumnFormat', columnformat,...
            'ColumnEditable', [false false true true],...

% Set width and height
t.Position(3) = t.Extent(3);
t.Position(4) = t.Extent(4);           

Related Examples

More About

expand all


Distances in pixels are independent of your system resolution on Windows® and Macintosh systems:

  • On Windows systems, a pixel is 1/96th of an inch.

  • On Macintosh systems, a pixel is 1/72nd of an inch.

On Linux® systems, the size of a pixel is determined by your system resolution.


If the ColumnEditable property is set to true for specific columns, the user can edit values in that column. By default, this property is set to false for all columns. If a noneditable column contains pop-up choices, then only the current choice is visible in the table.

The CellEditCallback function executes after the user edits a value and perform any of these actions:

  • Press the Enter key.

  • Click anywhere else within the table.

  • Click anywhere else within the same figure window, or in another figure window.

The CellSelectionCallback function executes when the user selects one or more table cells or modifies the current selection.

You cannot select table cells programmatically. Directly clicking cells is the only method of selection.

Introduced in R2008a

Was this topic helpful?