How to create a table name using a string variable?

151 views (last 30 days)
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 Comments
Walter Roberson
Walter Roberson on 3 Jun 2020
Mustafa Calcuttawala: please read the material at the link that Stephen posted. It shows a number of different possibilities.

Sign in to comment.

Accepted Answer

Gabor
Gabor on 4 Mar 2019
I guess I will just use a cell which I will be store the the variable for the "name that should be" and the table itself too...
Thank you
  1 Comment
Steven Lord
Steven Lord on 4 Mar 2019
Or you could create a struct array with one field that contains your table and name that field using either the struct function or dynamic field names.
thefield = 'snowstorm';
data = magic(4);
structOfTables = struct(thefield, data)
structOfTables2.(thefield) = data

Sign in to comment.

More Answers (2)

Walter Roberson
Walter Roberson on 4 Mar 2019

Gabor
Gabor on 8 Mar 2019
Thank you all

Categories

Find more on Characters and Strings in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!