LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

sorting array number in different ranges

Solved!
Go to solution

ok, thanks crossrulz. I got it.

Regards.

0 Kudos
Message 11 of 15
(928 Views)

In general, you need to decide if the thresholds should belong to the upper or lower range. The current code correspond to the "larger or equal" case of your original exmple, but of you want  "larger" instead, things ned to be adjusted slightly.

 

And yes, the ranges don't need to be spaced equally, the only requirement is that they are sorted and nondescending.

0 Kudos
Message 12 of 15
(912 Views)

@ben64 wrote:

Would using Search Ordered Table.vi solved the Inf issue?

 

Using Ordered Table.png

 


That's an interesting alternative. It is a bit more universal because it works also if the array is monotonically decreasing, so it is slightly more universal. It also throws an awful amount of code at the problem (you can inspect the internal code yourself! 😄 BTW: I hate the sequence locals! :o)). From my experience, the plain old "threshold array" is very efficient, so I don't know if "search ordered table" would provide any advantages. Would be interesting to do some benchmarks.

0 Kudos
Message 13 of 15
(908 Views)

@Fonsi wrote:
I added another case if I add negative values in ranges. I put one solution, I think it is effcient solution.

I don't understand why you need the duplicate color and sign check. Just seems to overcomplicate things. Typically the code should work sufficiently well in it's original form, even if the thresholds start out negative.

 

And yes, if the thresholds are really spaced equally, the math could be simplfied even more, because the fractional index is just a linear transform of the input data, later to be rounded to integer and coerced to the valid range. My code is for the general case with ranges of arbitrary lenght.

 

 

0 Kudos
Message 14 of 15
(899 Views)

Hello,

 

In this case I wanted assign color to the % of 2 SD (standard deviation) from the mean of range. Thats why I assign -25% to 25% green and so...

for example. If I have reference values of 27.5 to 35.5 and have result = 28.3. The %2SD is -80% so I assign color 0.

 

Regards.

0 Kudos
Message 15 of 15
(884 Views)