MATLAB: How to add a drop-down menu for a certain column in a UItable in App Designer

drop downuitable

I read data from excel file using readtable command as follows:
app.data=readtable("Data.xlsx",'Sheet',1);
app.UITable.Data = app.data;
app.UITable.ColumnName=app.data.Properties.VariableNames;
app.UITable.ColumnEditable = true;
The Data consists of 6 columns, I want to add drop-down menu to column 4, then a correspond value appears in column 5 based on the selection in column 4 and use the value in column 5 and multiple it with the value in column 3 and the asnwer appears in column 6

Best Answer

  • Refer to Matlabs documentation on the uitable's ColumnFormat property which demonstrates how to set up pop-up menus within a column of a uitable by setting that columns' format as a cell array of options.
    The ColumnEditable property of column 5 & 6 should be set to false since you plan to programmatically set those values.
    The rest can be achieved by table indexing and whatever math you apply.