I have two variables, $ u \in \{0,40\}$ and $\gamma \in \{0,1\}$. I take $10$ values of $u$ and $5$ values of $\gamma$ and using their combinations as a pair of input parameters, I perform some mathematical operations a total of $10*5 =50$ times.
Now, say for $u=40$ and $\gamma=0.5$, I performed my mathematical operations and generated a $120 \text{x}9$ matrix of data. I would like to be able to call this Matrix, $\mathrm{DataU40G5}$ so I can keep track of where the data came from.
Now
"Data" <> "U" <> ToString[Evaluate[u]] <> "G" <> ToString[Evaluate[gamma]]
creates a string that looks like $\mathrm{DataU40G5}$ but I am unable to use it as a variable name and feed data into it. How would I go about this?
Also, as I write this, I'm thinking that instead of doing all this, I can simply add the variables $u$ and $\gamma$ as columns to my records and have just one $(120*50)\text{x}(9+2)$ dimensional Matrix as my dataset.
Is this a better Idea? Even if it is, please answer the first question just so I can learn how to do that.
ToExpression
. That will allow you to convert your string to an expression. So if you build your entire string out, you can simply useToExpression
. Now note that this is almost never a good way to go about it (i.e., building complex strings and converting to expressions). The opportunities for bugs are high and its flexibility and possibilities for extensions are low. The right approach is to think of better data structures to handle the problem, but that's not the question here. $\endgroup$