Hi friends, how can I create multiple tables named as T1, T2, T3, ... and T(n) in a for loop.
for j=1:n
x=rand(5,1);
y=rand(5,1);
T(j)=table(x,y)
end;

 Respuesta aceptada

Stephen23
Stephen23 el 4 de Feb. de 2021
Editada: Stephen23 el 4 de Feb. de 2021

0 votos

Just use a cell array:
n = 5;
C = cell(1,n);
for j=1:n
x=rand(5,1);
y=rand(5,1);
C{k} = table(x,y);
end
Note that using one table is likely to be a better approach:

2 comentarios

Reza Hosseini Vedad
Reza Hosseini Vedad el 4 de Feb. de 2021
Thanks for your answer.
I created as you said a cell array but C=cell(n,1), so as a coloumn.
but now I need all rows of this cells in a single table, what can I do?
Thanks in advance.
Stephen23
Stephen23 el 4 de Feb. de 2021
"now I need all rows of this cells in a single table, what can I do?"
You can concatenate the contents of the cell array, e.g.:
T = vertcat(C{:});

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 4 de Feb. de 2021

Comentada:

el 4 de Feb. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by