Concatenate rows into a table using a for loop with app designer
14 次查看(过去 30 天)
显示 更早的评论
Here I have an app designer call back function where when the user selects 'Instant Charge' in the drop down menu and clicks the button, it will output all the values (a,b) in a table. Going from row to row, I am having trouble with concatenating a new row to the table. The code is set up in a for loop so that it indexes the value in array a and array b but once that row is outputted in the table, I would like the next index of a and b values to be stored in the second row of the table, and so on. In this example, there are about 300 rows that need to be added to the table. May I get some assistance with concatenating new rows to the same table. Thank you for your help.
0 个评论
采纳的回答
Sulaymon Eshkabilov
2023-2-10
Note that if you need to update the content of the table, then you should use one of these approaches:
(1) Update the table:
A = randi([-10, 10], 3, 1);
B = table(A);
for ii = 1:10
B.A(ii+3) = randi([-10, 10],1);
end
B
(2) Update the table:
% OR
K = [];
M = table(K);
for ii = 1:10
M{ii,:} = randi([-10, 10],1);
end
M
(3) Concatenate the tables with the same variable name:
P = randi([-10, 10],1);
W = table(P);
for jj = 1:5
P = (randi([-10,10],1));
U = table(P);
W = [W; U];
end
W
更多回答(1 个)
Sulaymon Eshkabilov
2023-2-10
Maybe you can try this approach:
for jj=1:5
for ii = 1:10
M(jj,ii) = randi([-10, 10],1);
end
end
M_tab = array2table(M)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Develop Apps Using App Designer 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!