LabVIEW Idea Exchange

cancel
Showing results for 
Search instead for 
Did you mean: 
0 Kudos
wiebe@CARYA

threshold array in reverse

Status: Declined

Any idea that has not received any kudos within a year after posting will be automatically declined. 

Like "Search 1D Array in reverse", but for the Threshold 1D Array function.

 

Also, there should be an option to find the first sample below a threshold.

 

When you want to find the start and the end of a peak, it's really messy to make code for it:

 

With these options,

 

1) Find threshold (set to high)

2) Find threshol (set to low), with start index the result of 1)

 

Without it you need:

 

1) Find the srart (only one function)

2) Reverse the array (this does not

3) Negate the array.

4) Negate the threshold

5) Find the threshold (starting from 0 or previous peak).

6) Find the real index (reletive from start)

7) Repeat 5 and 6 (we might have found a peak after the first peak, and we want the end of the first peak).

😎 Stop when the found index is past the start index (and then use the previous index), or when no index is found.

 

 

 

 

7 Comments
wiebe@CARYA
Knight of NI

in fact, it's a little bit easier, but it's still a pitty you have to do it.

AristosQueue (NI)
NI Employee (retired)

This is a mathematically impossible request according to the math experts that I consulted. The last threshold for an array is not the same as the first threshold of that array reversed. Consider the array [4, 5, 5, 6], looking for a threshold of 5. This is why the node includes a "Start Index" input -- to correctly find the last threshold, you have to find all the thresholds before it, and, having found that threshold, start your search again at the next index, proceeding until you get an index at the end of the array, then taking the previous found value.

 

In other words, finding the last threshold is still going to search all the way through the existing array. And when you find the first threshold, how far to skip past it is an open question that is dependent upon the algorithm you are running... in the [4, 5, 5, 6] case, is the last threshold index 1 or 2? That's something the programmer needs to decide, and appears to have so many options (exact equality, some epsilon, some epsilon as long as there's no decrease, etc...) that it isn't the sort of thing that could be enumerated in a poly VI of algorithms.

 

There is so much variation here that if you are searching for multiple thresholds in an array, you need to be choosing and controlling your own algorithm. The primitive function "Threshold 1D Array" allows people to build whatever algorithm they need for their application and needs to remain just that -- a primitive upon which more complex functionality may be built.

 

For these reasons, we are going to decline this idea. If you have a particular design for a new, more complex node -- including what sort of inputs you think would be valuable on such a node to be of maximal value to many users, not just your immediate project -- please post it as a new idea.

wiebe@CARYA
Knight of NI

I do not want to search multiple threshold.

 

The example gives the wrong idea, because, well, it's confusing..
 

What I mean is that the threshold 1D array will search for the first element higher then the threshold.

 

If you found the higher threshold, you'd often want the other side of the peak, so you need to search for a value below the threshold. The only way to do that is to negate the entire array (that can be very large), and negate the threshold. If we could switch the Threshold 1D Array to search the first item below the threshold, this would be a lot easier,

 

In general, you might want to find a value below the threshold, and the only option now is to negate both the 1D array and the threshod.

 

Another problem is when you want to search the first threshold from the end, like with search 1D array. Like Search 1D Array, you have to reverse the array, and subtract the result from the array size -1.

 

 

 

wiebe@CARYA
Knight of NI

So instead of this:

Threshold 1D Array.png

We can do this:

ideal.jpg

Note that the first is less obvious to read. It could be very inefficient, if the array is large.

 

wiebe@CARYA
Knight of NI

For searching from the back, instead of this:

Threshold 1D Array 2nd.png

We could do this:

ideal 2.jpg

Less drastic, but still an improvement.

 

wiebe@CARYA
Knight of NI

So we'd have 4 combinations:

ideal 3.jpg

Darren
Proven Zealot
Status changed to: Declined

Any idea that has not received any kudos within a year after posting will be automatically declined.