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.
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.
04-08-2021 03:08 PM
In the above I see how this works for integers....
How would it be entered for non-integers?
Even if I change the representation two double precision...
It still won't allow me to enter non-integers... Is there a special syntax?
04-08-2021 03:24 PM - edited 04-08-2021 03:26 PM
Hello,
Check the help about the Case Structure. I just read the following: "Case selector—Selects which case to execute based on the value of the input data. The input data can be a Boolean, string, integer, enumerated type or error cluster. The data type you wire to the case selector determines the allowed cases you can enter in the selector label."
So non-integer are not supported. And if you try to wire a non integer (double below), LabVIEW will coerce its value to an integer (red dot):
Hope this helps,
04-08-2021 03:28 PM
Yes it helps thank you..
04-08-2021 03:32 PM - edited 04-08-2021 03:33 PM
You may use additional logic, to check the value of a non-integer numeric, using the result of this intermediate logic as input for your case structure. I'm thinking about Comparison Functions and more specifically to In Range and Coerce Function
Best regards,
04-08-2021 03:34 PM
As said, floating point numbers can't be directly used.
However, if you want, you can get close by approximation, if your floating point numbers are guaranteed to be small enough. Instead of wiring them in directly, first multiply them by a power of 10 (say, 1000). Then choose one of the "Round" primitives, to round the number up, down, or to the nearest integer. Then wire that into the case structure. Then you can create a case like "2500..2875" that will run for any number that was originally between 2.5 and 2.875.
04-08-2021 03:59 PM
yes thank you all posted answers are very helpful...
04-08-2021 05:24 PM
@Kyle97330 wrote:
As said, floating point numbers can't be directly used.
However, if you want, you can get close by approximation, if your floating point numbers are guaranteed to be small enough. Instead of wiring them in directly, first multiply them by a power of 10 (say, 1000). Then choose one of the "Round" primitives, to round the number up, down, or to the nearest integer. Then wire that into the case structure. Then you can create a case like "2500..2875" that will run for any number that was originally between 2.5 and 2.875.
Also, while floating point numbers aren't directly supported, they will be coerced to an integer, so you can use a combo of Kyle's suggestion plus this knowledge to get you "close enough".
04-09-2021 10:45 AM - edited 04-09-2021 10:51 AM
For DBL, you would typically create a 1D array diagram constant containing all range boundaries (unique and sorted), then you would threshold into it with your test value and round down/up to get an integer corresponding to each range. Now you can add a case for multiple, adjacent or nonadjacent ranges as in your first post.
(Still you should be aware that all limitations of equal comparisons with DBL values still apply.)
Here is an example that uses the integer to index into an array of colors. You can wire it to a case structure instead.
04-09-2021 10:49 AM
excellent this post and the previous... Thank you