キャンセル
次の結果を表示 
次の代わりに検索 
もしかして: 

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

解決済み
解決策を見る

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 件の賞賛
メッセージ1/18
7,175件の閲覧回数

@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 件の賞賛
メッセージ2/18
7,165件の閲覧回数

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 件の賞賛
メッセージ3/18
7,164件の閲覧回数

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 件の賞賛
メッセージ4/18
7,162件の閲覧回数

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 件の賞賛
メッセージ5/18
7,158件の閲覧回数

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 件の賞賛
メッセージ6/18
7,153件の閲覧回数

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 件の賞賛
メッセージ7/18
7,152件の閲覧回数

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

0 件の賞賛
メッセージ8/18
7,139件の閲覧回数

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

0 件の賞賛
メッセージ9/18
7,133件の閲覧回数

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 件の賞賛
メッセージ10/18
7,126件の閲覧回数