LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Urgent : Array Comparison

Solved!
Go to solution

Hello, I need some urgent help if possible.

I'm fairly new to Labview but I do have a certain basics.

I'm trying to accomplish the following.

 

I have 2 arrays of the same size.

I'm comparing the elements of the first array to a certain value.

If some of the elements fits this requirement I want the compare the corresponding elements in the second array to another value.

If the elements of this second array are indeed greater then this new value I want to switch a boolean output to yes.

 

EXAMPLE!

 

Array1 =

1 2 6

5 4 9

3 7 2

 

Elements of Array1 > 5 ?

x x 6

x x 9

x 7 x

 

Array2 =

6 4 1

6 5 7

9 8 3

 

I only want to use the elements at the position corresponding to the elements from array1 that were greater then 5.

All other elements can be ignored.

 

New Array2 =

x x 1

x x 7

x 8 x

 

Elements of Array2 > 6 ?

x x x

x x 7

x 8 x

 

If Answer = 0 : Boolean = false

In this case : Answer = 2 elements : Boolean -> True

 

I could really use some help.

Any idea is welcome.

 

Thank you in advance.

0 Kudos
Message 1 of 7
(1,276 Views)
Solution
Accepted by topic author KLI

I would make both array comparisons.  You'd wind up with two arrays of boolean values.  Then AND those arrays together.  Now you have an array of booleans where a True means the element in the first array met condition 1 and the same element in the second array met condition 2.

0 Kudos
Message 2 of 7
(1,273 Views)

Nice Idea !

I will test this.

 

But how to know the positions in the arrays of these elements now?

 

 

0 Kudos
Message 3 of 7
(1,266 Views)

I am not sure I full understood but I threw this together really quick.

 

Seems to do what you wanted but it's ugly and I am sure there are better ways...

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 4 of 7
(1,262 Views)

There are many ways to do this.

  • Do you really need to know the positions? If you just need to know of a TRUE exists in the output, do an "OR array elements". If the output is true, at least one element is true.
  • Use "boolean to 0,1" followed by "add array elements". The value will tell how many elements are true.
  • You could use two stacked FOR loops and build an array of the TRUE indices of the final array in a shift register.
  • You could reshape the 2D array to a 1D array, use search 1D array in a loop to find all TRUEs (here is example code that could be adapted)

LabVIEW Champion. It all comes together in GCentral GCentral
What does "Engineering Redefined" mean??
0 Kudos
Message 5 of 7
(1,255 Views)

 


@RTSLVU wrote:

I am not sure I full understood but I threw this together really quick.

 

Seems to do what you wanted but it's ugly and I am sure there are better ways...


I responded to your duplicate thread and assumed single dimension arrays, so ignore my response.

 

 

========================
=== Engineer Ambiguously ===
========================
0 Kudos
Message 6 of 7
(1,229 Views)

: Thank You

0 Kudos
Message 7 of 7
(1,204 Views)