Concatenate rows into a table using a for loop with app designer
14 views (last 30 days)
Show older comments
Ratanjot
on 9 Feb 2023
Answered: Sulaymon Eshkabilov
on 10 Feb 2023
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 Comments
Accepted Answer
Sulaymon Eshkabilov
on 10 Feb 2023
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
More Answers (1)
Sulaymon Eshkabilov
on 10 Feb 2023
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 Comments
See Also
Categories
Find more on Develop Apps Using App Designer in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!