08-14-2018 09:30 AM - edited 08-14-2018 09:32 AM
The Array you provided has Column 1 values that have no positive jumps bigger than 0.005, and two that are bigger than 0.004. The following routine just handles increasing jumps -- a similar loop could also handle decreasing jumps, or, with a little extra logic, you could make it handle "delta" jumps (i.e. up or down). I'll walk you through the code --
The While loop is there to catch all the Jumps. We peel off Column 1, since that's where we are looking. We want to compare the current value with the previous value (to detect a jump), and initialize "previous value" to the first value (to avoid having the first element be an automatic jump). If the Jump is bigger than our Jump Size threshold, we have found it, exit the Loop, and save the Index of where we are. We use this to delete the previous rows from the 2D array, and return the value found in Column 0. We also return the cumulative Jump Indices (of the original 2D Array). Note that we only output numeric values if we find jumps -- if none are found, we output empty arrays.
I think this is what you were talking about ...
Bob Schor
P.S. -- If there are two sequential Jumps, I'm not 100% certain I would catch the second with my initialization scheme for the inner For loop. I leave this as an Exercise for the Reader.
08-14-2018 02:16 PM
08-14-2018 02:23 PM - edited 08-14-2018 02:23 PM
Hi RH,
- cleaning up the code would be nice. Delete dead code.
- In the central FOR loop you should use autoindexing of that 2D array.
- Why do you compare an integer with a float zero? Why not use the "==0" comparison?
- Do you really need to use local variables here?
- ...
But well: when it works for then its ok!
08-14-2018 02:54 PM
08-14-2018 03:16 PM - edited 08-14-2018 03:24 PM
Oh for Pete's sake! let me offer some help for y'all. I'm in Alabama so, I gets ta say "Y'all"
Threshold Array works on an array of points where a point element is a cluster of [X, Y]. Index Array works on 2D by column and, the the cluster and variant pallet contains Index and Bundle. So, who needs any loop except to offset the index to find all thresholds??? Hint: multiply the array of points by a cluster contsant of [-1,1] and the threshold by -1 to find negative transitions. A simple abs valvue of X(n+1 - n) before the index and bundle will work to identify jumps if you want them.
08-15-2018 01:08 AM