Using a column of cells as variable names in a table
Mostrar comentarios más antiguos
Hi!
I have a table that contains 2 columns each having 28 rows. The first column contains cells of strings, and the second one contains numbers in cell format. I want to use the individual strings from column 1 as the varible names for a table and then assign the numbers from 2nd column to those variables. How do I do that? The file is attached.
Any help will be appreciated.
Respuestas (2)
Here is how to get this assignment done:
T = readtable('Properties.xlsx');
T2 = table(T.Var2, 'RowNames',T.Var1)
T2 = rows2vars(T2)
T2.a1
T2.b1
T2.t1
T2.E_steel
...
2 comentarios
Prasenjit Dewanjee
el 18 de Feb. de 2023
Editada: Prasenjit Dewanjee
el 18 de Feb. de 2023
Sulaymon Eshkabilov
el 18 de Feb. de 2023
Editada: Sulaymon Eshkabilov
el 18 de Feb. de 2023
Most welcome.
Seth Furman
el 14 de Mzo. de 2023
Editada: Seth Furman
el 14 de Mzo. de 2023
See unstack.
t1 = readtable("Properties.xlsx")
t2 = unstack(t1,"Var2","Var1")
1 comentario
Stephen23
el 14 de Mzo. de 2023
+1 very neat
Categorías
Más información sobre Tables 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!