From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Discrete slide values from array

Solved!
Go to solution

Hello. I have a 1D array of double e.g. [1, 2.5, 3, 6.8, 10] and I would like to make a slide control, where user can choose only these exact values. Please note, that this example vector is very small and in reality I have "time" vector long more, than 100 numbers, so some manual inserting is not an option :).

I have already searched in "property node", but did not find anything useful.

Thank you in advance.

0 Kudos
Message 1 of 3
(3,897 Views)
Solution
Accepted by topic author zordix

Is the array always sorted?

 

You could use "threshold array" with your slide value and the array of sorted valid points, round the result to the nearest index, then use index array to get the valid value for further processing.

 

You could also subtract the silde value from your array, take the absolute value of the result and use array min&max to find the index of the nearest point.

 

Once the slide is released, you can write the valid value back to the slide (don't fight the user while he is operating it!).

 

A better solution might be to use an integer slide where each value correspond to the index of the array element. Hide the digital display and the scale and display the value in something that looks like a digital display but is actually a seperate indocator.

 

 

Message 2 of 3
(3,887 Views)

I thought it will not be that easy. Thank you for your suggestions, these two seem suit the best for me:

 

You could use "threshold array" with your slide value and the array of sorted valid points, round the result to the nearest index, then use index array to get the valid value for further processing.

 You could also subtract the silde value from your array, take the absolute value of the result and use array min&max to find the index of the nearest point.

 

The last one would be good, but it will make "unscaled" slide (the same size of gaps between numbers)

It is pity, that LabView can handle min-step-max, but can not have simply forced values. Maybe in the next version.

0 Kudos
Message 3 of 3
(3,844 Views)