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 #87458 is a reply to message #87449] Tue, 04 February 2014 06:41 Go to previous message
Mats Löfdahl is currently offline  Mats Löfdahl
Messages: 263
Registered: January 2012
Senior Member
Den tisdagen den 4:e februari 2014 kl. 14:27:53 UTC+1 skrev sid:
> Hello sir,
>
> The main problem is, I will have a resultant array of
> n=dblarr(i,j)
> j=25,
> but i is varying say around 800 to 900.
> so i should name it in a for loop like,
>
> n1=n(800,1)
> n2=n(830,2)
> n3=n(840,3)
> .
> .
> .
> like this it has to go till 25.

I assume you mean n1=n(0:799,0), etc?

But why do you have to make each column in the 2D array into a separate variable? Isn't the data fine where it is?

> Finally I have to save this n1,n2,n3,....,n25 into separate files,
> like
>
> openw,2,'test.dat'
> printf,2,n1
> close,2
>
> till n25

This should work just as well with the original 2D array. Assume you have the lengths of the columns in an array lengths=[800,830,840,...], you could do something like:

for i=0,24 do begin
openw,2,'test'+strtrim(i,2)+'.dat'
printf,2,n[0:lengths[i]-1,i]
close,2
end
[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: Fri Oct 10 06:23:13 PDT 2025

Total time taken to generate the page: 0.48084 seconds