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

Home » Public Forums » archive » Loop through arrays with different names
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: Loop through arrays with different names [message #55171 is a reply to message #55088] Thu, 02 August 2007 08:55 Go to previous messageGo to previous message
hazel is currently offline  hazel
Messages: 5
Registered: July 2007
Junior Member
On Aug 2, 7:27 am, greg.a...@googlemail.com wrote:
> On Aug 2, 2:04 am, hazel <hazel.ken...@gmail.com> wrote:
>
>
>
>> Hello,
>
>> I have a really simple problem that always happens when I starting
>> trying to use strings..
>
>> I want to loop through a series of arrays, each with a slightly
>> different name (det1arr(n,3), det2arr(n,3), det3arr(n,3)..etc..) and
>> subject each to the same function:
>
>> a quick outline is:
>
>> for j=1,8 do begin
>
>> for i=0, n-1 do begin
>
>> vx=det1arr(i, 0) ; where the 1 is effectively the value of 'j'
>> vy=det1arr(i, 1)
>> vz=det1arr(i, 2)
>
>> result(i,j)=some_function(vx, vy, vz)
>
>> endfor
>
>> So can I do something like: vx=det+j+arr(i,0)? (Only that clearly
>> won't work)? There must be a way? Otherwise I can reload all my
>> different arrays into one array I realise and just loop through that.
>
>> I'm sure it's something painfully simple and for that I apologise, but
>> it is the end of the day (for me anyway),
>
>> Thanks,
>
>> Hazel
>
> I'd vote for putting them in a single array. I'm pretty sure this will
> turn out the cleanest option. You can put them together like this:
>
> detarr=[[[det1arr]],[[det2arr]],... ]
>
> although it would likely be better to create them in a detarr(n,3,8)
> in the first place. You may find that you can carry out your entire
> calculation as an operation on the array, rather than chugging through
> all the elements.
>
> regards,
> greg

Thank-you all for your useful suggestions, problem solved!

Hazel
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Routine for Converting DN to Radiance to Temperature
Next Topic: Another HDF File Question

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

Current Time: Wed Oct 08 19:58:36 PDT 2025

Total time taken to generate the page: 0.00213 seconds