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

1 Ansicht (letzte 30 Tage)
Kim Lopez
Kim Lopez am 16 Okt. 2017
Beantwortet: Jan am 16 Okt. 2017
Assuming the user input a value which is 8. Then display the result in column from 0 to 8 as shown on the image.

Akzeptierte Antwort

Jan
Jan am 16 Okt. 2017
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;

Weitere Antworten (1)

Walter Roberson
Walter Roberson am 16 Okt. 2017
uitable, use a Data cell array with three columns, and configure the column names and column types.
  2 Kommentare
Kim Lopez
Kim Lopez am 16 Okt. 2017
Thanks for the reply sir. I already done that. What I want the code to show is it will display the value from 0 to the user input value in the first column. If the user input a value of 5, then it will count from 0 to 5 and display it in first column. I hope you've got my point.
Walter Roberson
Walter Roberson am 16 Okt. 2017
There are a number of ways to put data into a cell array, including a plain "for" loop.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulink finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by