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

Home » Public Forums » archive » Storing values in array after each iteration in for loop
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: Storing values in array after each iteration in for loop [message #91305 is a reply to message #91266] Sat, 27 June 2015 09:58 Go to previous message
Jeremy Bailin is currently offline  Jeremy Bailin
Messages: 618
Registered: April 2008
Senior Member
On Wednesday, June 24, 2015 at 11:41:50 PM UTC-4, Michael Galloy wrote:
> On 6/24/15 4:44 PM, kcs4315@g.rit.edu wrote:
>> Hi,
>>
>> I'm very new to IDL....
>>
>> Essentially what I want to do is after each iteration of a for loop,
>> store the value it produces in an array. I originally tried making
>> the array in the for loop but it was over written every time it went
>> through an iteration, so only the last value was stored and
>> everything else was 0. Is there an easy way to remedy this?
>
> I imagine it would be something like:
>
> x = fltarr(n)
> for i = 0L, n - 1L do begin
> x[i] = ; whatever processing you want to do here
> endfor
>
> Mike
> --
> Michael Galloy
> www.michaelgalloy.com
> Modern IDL: A Guide to IDL Programming (http://modernidl.idldev.com)

It's also worth noting that, depending on what exactly you're doing inside the for loop, you may be able to operate on full arrays at once instead of using a for loop. :)

-Jeremy.
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: cgScaleVector and diverging colorbar help
Next Topic: Identifying outliers in data

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

Current Time: Fri Oct 10 17:12:15 PDT 2025

Total time taken to generate the page: 1.27783 seconds