03-24-2016 07:58 AM
ok, thanks crossrulz. I got it.
Regards.
03-24-2016 09:50 AM
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.
03-24-2016 10:09 AM
@ben64 wrote:Would using Search Ordered Table.vi solved the Inf issue?
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.
03-24-2016 10:26 AM
@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.
03-24-2016 11:18 AM
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.