How to create a table name using a string variable?
显示 更早的评论
Hi,
How can I use a string variable for a table name?
eg.:
-----------------------------
T = 'ThisShouldBeMyTableName';
VariableNames = {'StartCash','EndDate'};
T = table(input_values.StartCash, input_values.EndDate, 'VariableNames',VariableNames);
-----------------------------
The table which is create should be named "ThisShouldBeMyTableName" not "T".
Thank you
3 个评论
Dynamically accessing variables names is one way that beginners force themselves into writing slow, complex, buggy code that is hard to debug. Read this to know some of the reasons why:
Use indexing. Indexing is simple, neat, and very efficient. Unlike what you are trying to do.
Mustafa Calcuttawala
2020-6-3
@stephen Can you please elaborate what you mean by indexing? How exactly do I use this indexing?
Walter Roberson
2020-6-3
Mustafa Calcuttawala: please read the material at the link that Stephen posted. It shows a number of different possibilities.
采纳的回答
更多回答(2 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Tables 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!