06-12-2019 12:49 PM
Hello,
I have an array of Boolean True/False. When part of the array is true I want to execute one command and when it is false I want to execute another. I thought of doing this using a case structure. However, I cannot connect a 1D array of Boolean values to the case structure because it says they are not the same type. Is there a solution to this where I can use the case structure with my array?
Thank You.
Solved! Go to Solution.
06-12-2019 01:01 PM
@lucasphee wrote:
When part of the array is true I want to execute one command and when it is false I want to execute another.
Can you explain this thought process? Knowing that, it'd be easy to find an answer for you. Without knowing that, it's difficult.
Do you care about a specific value/set of values in that array? If so, you can pull them out with an Index Array/Array Subset call.
Do you want it to execute if ANY elements are true? OR handles that.
Do they ALL need to be true? AND handles that.
Generally, the Case Structure can't guess which logic you want it to perform on that array. Because it's not sure what you care about in that array (same as me), it can't make a logical decision to execute a case. You'll need to explain here what your logic should be based on the various potential states of the array. With that, we can work together to find a way to put that into code so the case structure understands the same desire.
06-12-2019 01:02 PM - edited 06-12-2019 01:04 PM
lucasphee,
Case structures do not accept arrays. I would try using an AND Array Elements or OR Array Elements with your boolean array.
All the best,
06-12-2019 01:03 PM
A little more information is needed. When you say "part of the array is true" do you mean any part, a specific element, multiple specific elements, or something else?
06-12-2019 01:05 PM - edited 06-12-2019 01:47 PM
A case structure cannot look at "part of an array". There are functions such as "AND array elements" and "OR array elements" which takes a boolean array and outputs a TRUE if either at least one or all elements are true.
can you provide more details on the decision process?
(EDIT: Sorry, I started replying, but got side-tracked so everybody else was faster. 😉
06-12-2019 01:10 PM
Basically I start with two arrays. One is angles and one is current. When than angle value is 0-180 degrees, and the current corresponding with that angle is negative, I want to multiply it by -1. If it is positive I want to leave it as it is. For 180-360 degrees if it is positive I want to multiply it by -1, and if it is negative I want to leave it as it is. The two arrays that I start with are the same length and come off of a csv file. I so far created my boolean array for if the angle is <= 180 degrees and if the current value is < 0. If that is true, that element in the array is true, and I want to multiply the current element by -1.
06-12-2019 01:13 PM
There are of course some false elements as half the angles are greater than 180 and some of the currents corresponding to current less than 180 have negative values since these values in the csv file came from a measurement.
06-12-2019 01:25 PM
Put your case structure in a FOR loop. See the attached for an example.
06-12-2019 01:33 PM
You have a later version of LabView than me. Can you please provide a screenshot.
06-12-2019 01:42 PM - edited 06-12-2019 01:49 PM
How about forming a complex datatype (r, theta)? I think your description is way too complicated.
In the most general case, you would just autoindex on the arrays, process each pair of elements, and autoindex at the output tunnel to form the corrected arrays.
Can you attach a VI containing typical data?