Concatenate rows into a table using a for loop with app designer
조회 수: 13 (최근 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!