MATLAB: App designer Table with input numbers of rows and columns

checkboxMATLABstructurestable columns rows

Hello!
I want to create a table with the numbers of rows and columns previously requested to the user.
(the number of columns is given by app.colonna and the number of rows is given by app.slice)
In every cell I need a checkbox.
How can i create this table?
fig = uifigure;
tdata = table([false; false; false]);
uit = uitable(fig,'Data',tdata);
uit.Position(3) = 130;
uit.RowName = 'numbered';

Best Answer

You can create properties and set the values using following code
properties (Access = private)
Property % Description
colonna=3; %columns
slice=2; %rows
end
You can use following code to create table with the given number of rows and columns and with check boxes in each row.
methods (Access = private)
% Code that executes after component creation
function startupFcn(app)
fig = uifigure;
tdata = table('Size',[app.slice, app.colonna],'VariableTypes',["logical","string","string"]); % use “logical” to get checkbox in first column
uit = uitable(fig,'Data',tdata,'ColumnEditable',[true false false]); % columns can be editable if ColumnEditable is true
uit.Position(3) = 130;
uit.RowName = 'numbered';
end
end
Hope this helps!