so you want to compare a waveform with a fixed value?
Such a comparison will give you a boolean signal (aka array) and now you need to detect rising and falling edges in this boolean signal. Sounds like a good example to actually learn to code in LabVIEW…
You could also make some Rube Goldberg code to reverse the the 1D array, find the threshold there and subtract it from the array size to figure out B if you really wanted to use the threshold function again.
GerdW's suggestion is infinitely better though.
You don't need to reverse the 1D array, just negate it. Then falling becomes rising and vice versa but the indexes don't change.
Good point, although you then would need to round the first threshold's index towards positive infinity and use that as the starting index for the threshold of the negated array. If you didn't do that then it would always return 0 as the first element is already above the threshold.
I would use two arrays, the original and the negated. Search (or threshold) the original array for the threshold value until the threshold is found then search (or thershold) the negated array for the negated fhreshold value starting from the index where the first threshold was found. Both indexes will be correct and the values are correct except that the value of the second one will need to be negated to give the correct value.
And here we have arrived at a solution way more complicated than it needs to be that will only solve this one particular problem but will, in fact, work. Well done team.
Thanks for all the help
Please do not do what you marked as a solution in your program. If you do this it will only work for a continuous function that starts below the threshold, goes above it and then dips back down. This will also only return you the first and last time it crosses that threshold.
I would STRONGLY suggest you take GerdW or Alex's approach. They are both much better, I wish sarcasm showed through the internet better.