04-09-2010 07:48 PM
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
04-09-2010 09:57 PM
04-09-2010 10:34 PM
this may help:
04-10-2010 02:04 AM
There are 2 ways to compare arrays:
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.
04-10-2010 05:17 AM
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
04-10-2010 06:24 AM
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.
04-10-2010 01:39 PM
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
04-11-2010 01:29 AM
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
04-12-2010 10:40 AM
Lucither wrote:There are 2 ways to compare arrays:
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