LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Comparing Bool-Arrays where some values can be T or F

Solved!
Go to solution

Dear All,

 

I am trying to compare two Bool-Arrays (13 T/F values each) from which 4 are allowed to be T or F. I have to do that for four cases.

Up until now I have only found a work-around by using permutations or a very large 2D-Array.....which are both a real pain in the neck.

Is there a possibility to define a bool constant that can be T or F?

The array in the example only has 8 values of which 3 are allowed to be T or F. Now I have to expand this to 13/4.

 

Thanks for your help.

 

Ralf

0 Kudos
Message 1 of 15
(2,067 Views)

Hallo Eisbein,

 


@Eisbein wrote:

I am trying to compare two Bool-Arrays (13 T/F values each) from which 4 are allowed to be T or F.


Simple like that:

This will work for "any" array length (less then 2^15 elements and both arrays of same length) and any limit…

 

I'm not sure I got your requirement correctly. Anyway: when working with boolean data you can use all those boolean functions to ease the solution!

 


@Eisbein wrote:

Is there a possibility to define a bool constant that can be T or F?


A boolean value will always be TRUE or FALSE…

 

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 2 of 15
(2,060 Views)

Thanks, Gerd.

I know where you're coming from. Neat! But where some of the values don't matter if T or F, some do.

Sometime you just have to let go. 
I've just re-built the array I want to compare to the values that matter.

That seems to work.

 

Ralf

0 Kudos
Message 3 of 15
(2,030 Views)

Hi Eisbein,

 


@Eisbein wrote:

But where some of the values don't matter if T or F, some do.


So for example you want to test an array like TFTFXXTFTF, where two elements marked "XX" aren't relevant?

Use boolean functions like AND/OR to mask those bits, then you can use == (or <>) to compare your arrays!

 

You really should attach a VI containing example data and the expected output…

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 4 of 15
(2,023 Views)

@Eisbein wrote:

Thanks, Gerd.

I know where you're coming from. Neat! But where some of the values don't matter if T or F, some do.

Sometime you just have to let go. 
I've just re-built the array I want to compare to the values that matter.

That seems to work.

 

Ralf


Is this some sort of joke?

 

Why not just hardcode the "Right" answer?  

 

Seriously, you want to compare 13 pairs of true false elements and some of the values just don't mean anything.....

 

North Dakota,  move to North Dakota.  There is ample room between residents there and BONUS no Capital Punishment. 


"Should be" isn't "Is" -Jay
0 Kudos
Message 5 of 15
(2,003 Views)

As I said....I have to do this with several cases where the T/F that matter change position, and I have to do this within quite a few arrays.

A built-in function T/F instead of T or F within an array would have helped. In a single line for one value, a walk in a park, but within an array?

You don't like my question?......just don't reply!

You can't give a solution, a hint or an answer?........do the same!

 

R.

0 Kudos
Message 6 of 15
(1,998 Views)

It's because your not making sense. True is TRUE. False is FALSE. It's either one or the other. It can't be "when it feels like it."

 

We really need to see some example data of what data comes in and what you expect the answer to be. Upload your VI with data in your controls and set them to the default values, save the VI, and then import it here.

0 Kudos
Message 7 of 15
(1,993 Views)

The correct way to handle "TRUE/FALSE/DON'T CARE" is to use a mask, as GerdW mentioned.  If you have arrays of Booleans like in your picture, use an array of masks.

Bill
CLD
(Mid-Level minion.)
My support system ensures that I don't look totally incompetent.
Proud to say that I've progressed beyond knowing just enough to be dangerous. I now know enough to know that I have no clue about anything at all.
Humble author of the CLAD Nugget.
0 Kudos
Message 8 of 15
(1,985 Views)

Sometimes it matters, sometimes it doesn't, and that's exactly what I have here.

A VI does make little sense, but I have inluded one so that you see what I mean.

To control different features of a drive through OPC/Profi some measurement values need to be true, some don't. The positions are fixed, but change with each case.

Some would say, if it doens't matter just put in F or T, but I need a [T] after the comparison, no matter what F/T value the measurment gives.

If Labview had an [ignore] value like the TIA/Siemens everyting would be fine, and that is exactly my question.

0 Kudos
Message 9 of 15
(1,972 Views)
Solution
Accepted by topic author Eisbein

As others have said, you need an array to mask the results that you don't care about.

Then simple boolean operations handle the rest.

 

See attached.

Message 10 of 15
(1,967 Views)