LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Help searching 1D array

I'm looking for a way to find the values (and their indices) closest to a specific value that I input in a 1D array. My data is a peak so there are 2 values that I need to find. I can find one of them by subtracting the value from the array, taking the absolute value, and then finding the minimum but I can't figure out how to find the other value.
Thanks
0 Kudos
Message 1 of 5
(2,909 Views)
You could remove the first value you find from the array and perform the same search again. If you are trying to find the two values on either side of the peak, you could try to determine for each element whether it is in an ascending or descending section.
Maybe you can explain the problem with a little more detail?
0 Kudos
Message 2 of 5
(2,899 Views)
You could use the Threshold 1D array function. "It finds a pair of consecutive elements such that threshold y is greater than the value of the first element and less than or equal to the value of the second element". Run it a second time after reversing the 1D array. See the attached vi.
Chilly Charly    (aka CC)
0 Kudos
Message 3 of 5
(2,897 Views)
Attached is a variation that multiplies the array by -1 instead of reversing it. This has some advantages. For example, if you are mostly interested in the distance between thw two points (e.g. peak width), errors due to noise will tent to cancel, while with array reversal, you get a systematic increase in width with increasing noise.
 
Is the peak a well known mathematical shape (Lorentzian, Gaussian, ?) Maybe you could fit it using Levenberg-Marquardt?
0 Kudos
Message 4 of 5
(2,884 Views)
Thanks for the help. I think I have it working now. I used a modified version of Peak Finder.


0 Kudos
Message 5 of 5
(2,842 Views)