comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » name a variable with number
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: name a variable with number [message #87453 is a reply to message #87449] Tue, 04 February 2014 05:50 Go to previous messageGo to previous message
rjp23 is currently offline  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).
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: accessing IDL internal (aka "built-in") routines
Next Topic: Error using data structures while reading ASCII file with different data types

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Thu Oct 09 20:44:23 PDT 2025

Total time taken to generate the page: 1.13505 seconds