Creating a Dynamic Table using push button in Matlab GUI

Hello,
I am creating a dynamic table using Matlab GUI, so far it is going good. I will atach my code:
function EVRIM_GUI
f = figure('Visible','off','Units', 'centimeters', 'Position',[1.5,1.5,28,16.5]);
CreateBoundary = uicontrol('Style','pushbutton','String','CreateBoundary','Units', 'centimeters','Position',[21.5,8,3,1],'Callback',{@CreateBoundary_Callback});
AssemblyData5 = {0,0,0,0};
function CreateBoundary_Callback(source,eventdata)
AssemblyTable5= uitable(f, 'Units', 'centimeters','Position', [12,1,9,5], 'Data', AssemblyData5,'ColumnEditable',[true, true, true,true], 'ColumnName',{'Position/m'; 'BodayName1';'BodyName2';'Type'},'CellEditCallback', {@AssemblyEdit_Callback5});
for TempIndex5= 1:4
AssemblyData5{TempIndex5,1} = 0
AssemblyData5{TempIndex5,2} = 0;
AssemblyData5{TempIndex5,3} = 0;
AssemblyData5{TempIndex5,4} = 0;
end
set(AssemblyTable5, 'Data',AssemblyData5);
end
I want to remove the for loop to create the number of rows in the table, it should only display 1 row initially, and when the user enters the data in the row and presses enter, another row should appear.
Does anybody knows what to change in it?

 採用された回答

Chris Dan
Chris Dan 2020 年 7 月 8 日

0 投票

I found the answer:
function CreateBoundary_Callback(source,eventdata)
set(AssemblyTable5, 'visible', 'on')
data = get(AssemblyTable5, 'data');
data(end+1,:)={0};
set(AssemblyTable5,'data',data)
end

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeHistorical Contests についてさらに検索

質問済み:

2020 年 7 月 7 日

回答済み:

2020 年 7 月 8 日

Community Treasure Hunt

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

Start Hunting!

Translated by