LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Connecting 1D array of Boolean True/False to Case Structure

Solved!
Go to solution

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.

0 Kudos
Message 1 of 18
(5,968 Views)

@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.

0 Kudos
Message 2 of 18
(5,958 Views)

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,

0 Kudos
Message 3 of 18
(5,957 Views)

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? 

 

0 Kudos
Message 4 of 18
(5,955 Views)

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. 😉

0 Kudos
Message 5 of 18
(5,951 Views)

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.

0 Kudos
Message 6 of 18
(5,946 Views)

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.

0 Kudos
Message 7 of 18
(5,945 Views)

Put your case structure in a FOR loop. See the attached for an example.

0 Kudos
Message 8 of 18
(5,932 Views)

You have a later version of LabView than me.  Can you please provide a screenshot.

0 Kudos
Message 9 of 18
(5,926 Views)

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?

0 Kudos
Message 10 of 18
(5,919 Views)