12

3

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.

1

See this question: http://mathematica.stackexchange.com/q/9974/5

– rm -rf – 2012-08-31T23:50:52.787Thanks R.M. I had seen that before posting but it seemed very complicated and tied to the complicated formulation of that question. I was hoping that my simpler problem would have a simpler answer. I will go read that thread and figure it out now. Thanks. – Amatya – 2012-09-01T00:14:24.940

Hmm, that answer is probably not useful here. Try looking into the documentation for

`ToExpression`

. That will allow you to convert your string to an expression. So if you build your entire string out, you can simply use`ToExpression`

. 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. – rm -rf – 2012-09-01T00:22:09.830