How to expand a table with more columns?
34 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Leon
el 30 de Sept. de 2021
Comentada: Leon
el 30 de Sept. de 2021
I have a table T1 with a size of 30000 x 55.
How do I add 6 more columns of this table: A, B, C, D, E, F, each of them have a size of 300000 x 1.
I tried to first form a new table
T2 = table(A, B, C, E, E, F);
and then join them together:
T_new = join(T1, T2);
Here is the error:
Error using tabular/join (line 130)
Cannot find a common table variable to use as a key variable.
0 comentarios
Respuesta aceptada
Dave B
el 30 de Sept. de 2021
Editada: Dave B
el 30 de Sept. de 2021
You can use the [ ] syntax to concatenate them, just like with a matrix (make sure that they don't share variable names):
a=rand(10,1);
b=rand(10,1);
T1=table(a,b)
c=rand(10,1);
d=rand(10,1);
T2=table(c,d)
T3=[T1 T2]
Alternatively, if you want to use join, you just need something to join them on (something which identfies which rows are the same in the two tables). You can use an existing index variable, or the RowNames property for this:
T1.Properties.RowNames=string(1:height(T1))';
T2.Properties.RowNames=string(1:height(T2))';
T4=join(T1,T2,'Keys','Row')
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!