LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

comparing arrays

Hello, I am new to labview, just finished the core 1 course.   Here's my problem I am trying to compare elements between 2 2d arrays.  I am checking to verify the memory data from a nvm chip.  the memory is saved as a text file.  i will put the data into an array with 2 columns, one for the address the other for the data.  I will compare that array with a reference array.  most of the data must be an exact match, but some have a range. I would like to check the data, determine if it ok and output the rows that fail the check

thanks

0 Kudos
Message 1 of 9
(5,106 Views)
well if you want to compare whether 2 2d arrays are the same than just wire tham to an equal VI, but if you want to compare individual elements within the array you can use an index array and than  equal.vi
Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 2 of 9
(5,089 Views)

this may help:

 

 

 

Harold Timmis
htimmis@fit.edu
Orlando,Fl
*Kudos always welcome:)
Message 3 of 9
(5,084 Views)

There are 2 ways to compare arrays:

 

Array Equals Example Snippet.png

 

You can right click on the equals function. In the 'Comparison Mode' you can select 'Compare Elements' or 'Compare Aggregates'. Compare elements compares each value within an array with its corrosponding value and returns a boolean array of which values are equal and which are not. Compare Aggregates compares the arrays as a whole and returns a single boolean value depending on whether both Arrays are identical or not.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 4 of 9
(5,065 Views)

ok, i believe your suggestions will take care of the elements that must be equal.  Any suggestions on handling the elements that must fall within a range.  i would like to verify this data address by address and return the results including the address column the data column and a results column.

thanks

0 Kudos
Message 5 of 9
(5,049 Views)

How big is the Array? If i was doing this i would most probably add another column to your comparing array. the extra column would have the range the data needs to be within to pass. I would set the range to 0 if it needs to be exact and the range number if it needs to be within a range. This is assuming that the range can be defined as a single number, ie if 2 the data can be within +/- 2 of the read data. If it is more specific then this then you could add another column. The columns would then indicate min range - max range. All this data could then be used in a loop with a simple alogrithm to determine whether each value is either exact or within the specified range. If it is not, save the information you want and output that to an error array. Display this array upon exiting the loop.

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
Message 6 of 9
(5,039 Views)

I agree that i should add an additional column for the ranges.  The array will have a little over a 1000 rows.  Do you happen to have an example code.

thanks for all the help

0 Kudos
Message 7 of 9
(5,020 Views)

Dray,

 

You should really give more information and at least some sample code of what you have achieved so far. Otherwise it appears that you are not trying to tackle this issue yourself, just relying on other people to do your homework.

 

With regards to your array. What percentage of the array will need to be within a range? if you are only talking about a very small percentage that needs to be within a range and the rest needs to be exact then i wouldnt add an extra column to the comparison array. Instead i would make a seperate array that has 2 columns. The first column would hold the index of a value in the comparison array that needs to have a range, the second column would hold the range data. That way in your loop you can check whether the index you are currently checking matches an index value in your range array. If it does you can test it for range, otherwise just test that it is an exact match. If however a large percentage of the values need checking against a range i would add the extra column to the comparison array.

 

Now that you know what to do implementing this should not be a problem. If you are unsure then you should read any of the numerous resources labview provides for free on there website to get started. If you do start but get stuck, or it is not working as you wish, post what you have attempted and people will be more then happy to guide you.

 

Good luck.

 

Rgs,

 

Lucither

------------------------------------------------------------------------------------------------------
"Everything should be made as simple as possible but no simpler"
0 Kudos
Message 8 of 9
(4,976 Views)

Lucither wrote:

There are 2 ways to compare arrays:

 

Array Equals Example Snippet.png

 

You can right click on the equals function. In the 'Comparison Mode' you can select 'Compare Elements' or 'Compare Aggregates'. Compare elements compares each value within an array with its corrosponding value and returns a boolean array of which values are equal and which are not. Compare Aggregates compares the arrays as a whole and returns a single boolean value depending on whether both Arrays are identical or not.


 

Depending on the situation you may want to check the array lengths as well since the checks stop at the end of the sorter array.

 

The "In Range and Coerce" can be useful as well. Make usre you right click to enusre the upper limit is included so it does not fail the equal checks.

 

Ben

Retired Senior Automation Systems Architect with Data Science Automation LabVIEW Champion Knight of NI and Prepper LinkedIn Profile YouTube Channel
Message 9 of 9
(4,939 Views)