How to store two tables resulting from a for loop
Mostrar comentarios más antiguos
Hi guys,
I have a for loop with two iterations, and each iteration results into a table.
I would like to know whether it is possible to store the two tables coming out of the for loop such that I do not get the table from the first iteration overwritten from the second one.
Thanks for your help in advance.
Respuesta aceptada
Más respuestas (3)
Elias Gule
el 13 de Jul. de 2017
Ok, I now understand what you want.
numIters = 3;
tables = cell(numIters,1); % A cell array to store the tables
for index = 1 : numIters
t0 = table();
tables{index} = t0;
end
1 comentario
Konstantinos Tsitsilonis
el 13 de Jul. de 2017
Elias Gule
el 13 de Jul. de 2017
Try this.
t1 = table();
t1.Name = 'My Name';
t1.Age = 89;
data = table();
data.Name = 'Your Name';
data.Age = 15;
% Append data contained in the t1 table to the data table
data = vertcat(data,t1);
2 comentarios
Konstantinos Tsitsilonis
el 13 de Jul. de 2017
Editada: Konstantinos Tsitsilonis
el 13 de Jul. de 2017
Pappu Murthy
el 18 de Mayo de 2018
the statement "data = vertcat(data,t1); produced and error. Could not concatenate the table variable 'Name' using VERTCAT.
Caused by: Error using vertcat Dimensions of arrays being concatenated are not consistent.
Jose Rego Terol
el 19 de Oct. de 2019
Hi!
This thread is being very useful but I cannot find the way to save my tables in a excel file.
Here is the code
for jj = 1 : length(theFiles)
Table_parameters_spike = table(T,Q_spike,I_max,AT_HW,AT_RT)
filename = sprintf( 'Spike_%d', jj );
writetable(Table_parameters_spike, filename)
end
I got 5 .txt files but my objective is to get 1 .xls file with all the tables (2x5) concatenate vertically
Thanks!
1 comentario
Daisy
el 25 de Mzo. de 2022
Hi! Did you ever manage to figure this out? I have the exact same question..
Categorías
Más información sobre Whos en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!