Re: Incrementing an Array [message #24902 is a reply to message #24901] |
Fri, 27 April 2001 14:14  |
Craig Markwardt
Messages: 1869 Registered: November 1996
|
Senior Member |
|
|
s007amf@news.wright.edu (ALAN FRAZIER) writes:
> Once again I am struggling with the finer points of IDL. What I am trying
> to do seems simple, but is causing me some headaches. What I am trying to
> do is this:
>
> matrix[x,y,z] = matrix[x,y,z] + 1
>
> Where matrix is a 3D array and x,y,z are 1D arrays. Matrix starts out
> all 0's and I am trying to increment values at elements [x,y,z]. The
> problem
> is that some elements should be incremented multiple times. All the
> proper elements are incremented once, but the second, third,
> fourth....increments are not showing up. Any ideas? I know that I could
> write this with loops, but that would be too slow.
This is a common error using array indices. The problem is that each
element evaluated in parallel, not in sequence.
You really want to use HISTOGRAM for this one. JD Smith wrote an
n-dimensional histogramming function which you can find here:
http://cow.physics.wisc.edu/~craigm/idl/archive/msg05549.htm l
Craig
--
------------------------------------------------------------ --------------
Craig B. Markwardt, Ph.D. EMAIL: craigmnet@cow.physics.wisc.edu
Astrophysics, IDL, Finance, Derivatives | Remove "net" for better response
------------------------------------------------------------ --------------
|
|
|