Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To assign cell values as row and column names in a MATLAB uitable, follow these steps:

  1. Define your table data as a cell array. Let's suppose your data is stored in a variable called myData.

  2. Create a new figure to hold the uitable, and then create the uitable itself.

f = figure;
t = uitable(f);
  1. Set the data property of the uitable to your cell array.
t.Data = myData;
  1. Set the row and column names properties of the uitable to your desired values. You can either use a cell array of strings, or a vector of numbers.
t.RowName = {'row1', 'row2', 'row3'};
t.ColumnName = {'col1', 'col2', 'col3'};

Alternatively, you can specify the row and column names in the same cell array as your data, and use the 'ColumnName' and 'RowName' options when creating the uitable.

t = uitable(f, 'Data', myData, 'ColumnName', {'col1', 'col2', 'col3'}, 'RowName', {'row1', 'row2', 'row3'});