Re: name a variable with number [message #87453 is a reply to message #87449] |
Tue, 04 February 2014 05:50   |
rjp23
Messages: 97 Registered: June 2010
|
Member |
|
|
On Tuesday, February 4, 2014 10:35:27 AM UTC, sid wrote:
> Hello everyone,
>
> How to name a variable with number, for example,
>
> if nn=dblarr(800)
>
> I have to save it in this way n1=nn
>
> similarly upto n25
>
> Please let me know if you can help me out in this regard
>
> thanking you in advance
>
> sid
This is probably a "bad" way of doing it but I often use "execute" to generate variable names dynamically based on the contents of other variables which I think sounds like what you want to do.
For example:
for j=0, 24 do blah=execute('n'+strtrim(j,2)+'=nn[*,j]')
This will create the 25 arrays named n0, n1, n2, etc that contain nn[0,*], etc.
I'd be interested in what David et al. this of this as I end up using it quite often (but in more complicated situations).
|
|
|