LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Find values in an array using math

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 --

Threshold.pngThe 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.

0 Kudos
Message 11 of 16
(685 Views)
I got it! I had to remove the reverse array and connect directly to the Index array to see the row and column inputs. Once I did that everything became easy. I thank you all very much for trying. Here's what I ended up with. It measures the trip point of a Zener diode once with voltage sweeping 0 to 5V and again 5 to 0V and subtracts one value from the other for the hysteresis measurement. The zener is just to test my code, I have to test a lot of ICs for thresholds and hysteresis on many pins. This will make my job much easier.
0 Kudos
Message 12 of 16
(671 Views)

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!

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 13 of 16
(667 Views)
There isn't any dead code, I'm just showing a small piece of a larger VI. I'm afraid to mess with my working code when I don't have a firm grasp of autoindexing. I may try though. I'm comparing my sweep currents to .001 or 1mA because most of the data is either way below or above that value. The local variables already have the data I need to do the math on. How else would I do it?
0 Kudos
Message 14 of 16
(662 Views)

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.


"Should be" isn't "Is" -Jay
0 Kudos
Message 15 of 16
(659 Views)

Hi RH,

 

There isn't any dead code,

There is an IndexArray followed by ArraySubset just in the center of your image, which produce NO OUTPUT!

Dead code…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 16 of 16
(635 Views)