MATLAB: How to make an editable uitable with one categorical column

categoricalcolumneditableeditableMATLABtableuifigureuitable

Hello,
I am trying to create an app with an uitable which uses a dropdown as a first row and then several numeric cells that I would like to be editable by the user. Following the exemples of the matlab website i first create a table with the right configuration and then create a uitable and set the data of the uitable equal to the first table :
Color = {'red'; 'red'; 'green'};
width = {10; 20; 30};
height = {100; 200; 300};
tableData = table(Color, width, height);
tableData.Color = categorical({'red'; 'red'; 'green'}, {'red'; 'white'; 'yellow'; 'green'});
uif = uifigure();
uit = uitable('Parent', uif);
uit.Data = tableData;
uit.ColumnEditable = true(1,3);
I then receive this warning :
Warning: ColumnEditable value can be true only for char, string, double, logical, datetime and categorical columns.
I have tried to specify the ColumnFormat :
Color = {'red'; 'red'; 'green'};
width = {10; 20; 30};
height = {100; 200; 300};
tableData = table(Color, width, height);
tableData.Color = categorical({'red'; 'red'; 'green'}, {'red'; 'white'; 'yellow'; 'green'});
uif = uifigure();
uit = uitable('Parent', uif);
%%%%%%%%

uit.ColumnFormat = {'char', 'numeric', 'numeric'};
%%%%%%%%
uit.Data = tableData;
uit.ColumnEditable = true(1,3);
And i get the following warning :
Warning: ColumnEditable value can be true only for char, string, double, logical, datetime and categorical columns.
Warning: 'ColumnFormat' value has no effect when 'Data' value is a table array.
And the uitable can not be edited except for the first column in both case. What am I doing wrong ?

Best Answer

The reason is the uitable's 2nd and 3rd columns are cell array.
You should create them as double arrays like below with brackets not with curly braces:
width = [10; 20; 30];
height = [100; 200; 300];
Related Question