Best method of gathering varying amounts of user data via dialog boxes?

1 回表示 (過去 30 日間)
Jesse S
Jesse S 2017 年 4 月 18 日
編集済み: Walter Roberson 2017 年 4 月 24 日
I am aiming to create a dialog box that takes two numerical quantities from the user and simply save it to two matrices upon pressing the 'OK' button. The user is essentially building 'layers' of material and is inputting a thickness and an angle associated with each layer. The total number of 'layers' can range 1 < n < 64. Therefore I am looking for the ability to add additional rows of inputs on demand (by pressing a +new layer button), or use a table of sorts (like the one below), so the dialog box doesn't start with 64 blank lines.
This is similar to what I have in mind, except the table on the left would be editable or replaced by text boxes:
Thank you!

採用された回答

Ankit Bhardwaj
Ankit Bhardwaj 2017 年 4 月 24 日
編集済み: Walter Roberson 2017 年 4 月 24 日
You can use a uitable. You can define a push button callback which increases the size of your table by one every time the button is pushed. Here is a sample code which increases the size of the uitable by one with a push button callback. Please note that this code populates the table with random integers. You may need to modify this based on your workflow.
function variableTable
f = figure;
t = uitable(f,'Data',randi(100,10,3),'Position',[20 20 262 204]);
b = uicontrol('Style','pushbutton','Position',[300 20 250 40],'Callback', @(s,e) pushButtonCB(s,e,t));
function pushButtonCB(s,e,t)
row = randi(100,1,3);
t.Data = [t.Data;row];
  1 件のコメント
Jesse S
Jesse S 2017 年 4 月 24 日
Thank you! I ended up basically using this method, resulting in the following dialog box. The + - buttons add rows to the table.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSimulink Environment Customization についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by