Introduce columns in a table- Variables
显示 更早的评论
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 个)
the cyclist
2017-2-7
% 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 个评论
Patrick Brown
2017-2-8
the cyclist
2017-2-8
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);
类别
在 帮助中心 和 File Exchange 中查找有关 Tables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!