MATLAB: Count numbers from 0 to a value input by the user in uitable

uitable

Assuming the user input a value which is 8. Then display the result in column from 0 to 8 as shown on the image.

Best Answer

n = input('Number of rows: ');
Data = cell(n+1, 3);
Data(:,1) = num2cell((0:n).');
f = figure;
t = uitable(f);
t.ColumnName = {'User Input', 'Capacity Available', 'Probability'};
t.ColumnEditable = [false, true, true];
t.Data = Data;