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

Home » Public Forums » archive » Re: Calculating difference between each element in array from previous
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: Calculating difference between each element in array from previous [message #83807 is a reply to message #83671] Fri, 29 March 2013 17:07 Go to previous message
Phillip Bitzer is currently offline  Phillip Bitzer
Messages: 223
Registered: June 2006
Senior Member
For a start, I think I see where you are differencing adjacent elements of an array. This can be done without looping:

diff = arr - SHIFT(arr, 1)

Note SHIFT will wrap around values, so if that's not important you'll want to "mask" this values somehow.

And then, something like

ind = WHERE(ABS(diff) LE 500., lowCount, NCOMPLEMENT=highCount)

will give you the number of values less than your 500 critical value (lowCount) and greater than 500 (highCount).

I *think* this is what you're asking...

BTW, you should be *very* careful using parentheses to access your array elements. It is much better (safer) to do arr[indices]. There are reasons for this, and a good example of why can be found here:

http://www.idlcoyote.com/misc_tips/imagevarname.php

It is *highly* recommended you get in the habit of putting

compile_opt idl2

in all your routines.
[Message index]
 
Read Message
Read Message
Previous Topic: Re: Regression fit and random noise
Next Topic: Using where to create new variables of data

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

Current Time: Mon Oct 20 09:58:51 PDT 2025

Total time taken to generate the page: 1.84017 seconds