MATLAB: App designer ui table drop down selection

app designerdrop down menuMATLABuitable

Hi,
How can I make cells inside App Designer UITable selectable via drop down menu only but not editable as string?
i.e. I need to limit the possible values of these cells using drop down selection to a list of categorical array, and not letting user type whatever they want.
Thanks

Best Answer

Hi Jimmy,
You can achieve this by making your categorical array protected. Example:
B = categorical(A, 'Protected', true)
This will protect your drop-down menu from edits.
Full implementation of an example:
fig = uifigure;
myData = {'Andrew' 31 'Male'; ...
'Bob' 41 'Male'; ...
'Anne' 20 'Female';};
myData = cell2table(myData, 'VariableNames', {'Name', 'Age','Gender'});
myData.Group = categorical({'Group 1'; 'Group 2'; 'Group 3'}, 'Protected', true);
uit = uitable('Parent', fig, ...
'Position', [100 150 380 100], ...
'ColumnEditable',true, ...
'Data',myData);