Introduce columns in a table- Variables
Mostrar comentarios más antiguos
Hi, I want to introduce columns in a table, then I write Table.a but a is a variable string and I want that the column has the name of this string how I can do that???
1 comentario
Patrick Brown
el 7 de Feb. de 2017
Respuesta aceptada
Más respuestas (1)
the cyclist
el 7 de Feb. de 2017
% Create the table
x = rand(3,1);
tbl = table(x);
% Create the string that contains the variable name
varString = 'x';
% Access that variable, using the string
tbl(:,varString)
2 comentarios
Patrick Brown
el 8 de Feb. de 2017
the cyclist
el 8 de Feb. de 2017
This is also possible:
% Create the string that contains the variable name
varString = {'velocity'};
% Create the table with the name
x = rand(3,1);
tbl = table(x,'VariableName',varString);
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!