Compare arrays

Hello all, I am new to labview and i am trying to compare two arrays to see if they are equal. What i am trying to do is read cell values from excel and move them into an array. Then i would like to compare that array with a constant array in my labview program. Any help is greatly appreciated.

Do attention with the "aggregates" function.
Comparing two arrays, for example 3,2,1,0 and 3,2,1 gives "different"
When comparing if all values in an array are zero, the dimension must also be right !
So before comparing the values, I compare the length, causing an error if unequeal.
In my case, compare if everything is zero, I use the "Array max&min" function. (Max<>0 and Min <>0)
Message Edited by ST5 on 08-11-2009 05:00 AM

Similar Messages

  • Comparing arrays - help!

    Hello. I've been trying to solve this problem for hours, and I would be most grateful for any help you can give me.
    Basically, I'm trying to compare two arrays of char and tell first how many are the same in the same place (I can do that) and then how many are the same but not in place. However, if there are two of one char in one array, and one of the same char in the other, I only want to count it once.
    The problem is, I can't figure out how to do this. I'm using for loops and then setting the char to 0 if it finds a match. This doesn't work. I tried using a series of if statements but I got weird run time acceptions sometimes, and when I put in more if statements to combat that, 1.) it got too confusing and 2.) still only worked half the time. So I'm back to the for loops.
    Here's what I have:
    for (int j = 0; j<guess1.length; j++){
    for(int k = 0; k<code1.length; k++){
    if(code1[k]== guess1[j]){
    code1[k]=0;
    guess1[j] = 0;
    almost = almost + 1;
    So if the code is BBYG and the guess is BWWY, it should return 1 correct and one almost. It will return the one correct, but then return 3 for the almost. It looks at the B in guess which already returned the correct and find it an almost against both B's. When it should have been set to 0 in the correct for loop.
    Sorry, I ramble a bit. Hope you can help!
    Thanks.

    You're gonna love this.
    Unless you have some annoying and patently backward lecturer who wants you to everything the hard way then get ye nose into:
    1. the Collections framework.
    http://java.sun.com/docs/books/tutorial/collections/index.html
    2. and the Collections class itself.
    http://java.sun.com/javase/6/docs/api/java/util/Collections.html
    Hint: a Map can be used to find the distinct items in a list.

  • How to compare array of String with column of a table

    Hi,
    i have a array of string(say array is of length 1000). I want to
    compare those string in array with one table column
            - whether that table column has a string
                            if yes
                                            do nothing.
                            if no
                                            then insert that string into table.
            - whether table has obsolete row i.e, the one present in table and
    not in array
                            then delete that row.
    How do i go about this, because i see, it is not feasible to loop
    through array and search table to find new string OR loop through each
    row from table to find some obsolete row
    How can i accomplish this task more feasibly(without running query for
    each string, for comparission)? Is there any way to find this kind of
    problem. I would have been easy if i had to compare two tables(with
    UNION and INTERSECT), but it is not the case.
    thanks,
    kath.

    I'm not sure, whether I understand your problem correctly. Only two comments:
    - if both arrays are sorted, all can be done running exactly once simultaneously through both arrays.
    - if the column is marked as UNIQUE, all column strings will be different. I.e. you cannot insert the same string a second time.
    Regards  Thomas

  • Comparing array elements for equality

    Hi
    I have written a simple program that works as a lottery number predictor. It works fine except for the fact that sometimes 2 numbers will be the same. Does anyone know of a method that compares an array element to the others to test for equality?

    ok I've had a go at implementing a solution. I worked it out on paper so I haven't tested it yet in the program. Let me know if you can see any errors that I can't.
       boolean numNotSame = true;
       int[] lottery = new int[5];
       int currentNumber;
       start:  //label to return to if 2 numbers are the same
       while(numNotSame){
          for( int j = 0; j < lottery.length; j++){
              currentNumber = 1 + randomNumbers.nextInt(34);   //get random number
              for( int i = 0; i < lottery.length; i++){
                 if( currentNumber == lottery)
    continue start; //if numbers are the same begin again
    } //end inner for
    lottery[ j ] = currentNumber; //set array element if number not used yet
    } //end outer for loop
    numNotSame = false; //set false so while loop will end
    } //end while block

  • Comparing array members

    i cant solve the 2nd part of this prob (found in this forum):
    // Generate lottery numbers (from 1-49)
    // Print number of occurrences of each number
    public class Lotaria {
         public static void main(String[] args) {
              int x = 1;
              int p = 1;
              int s = 1;
              int n = 1;
              int[] loto = new int[49];    // n?s do loto
              // Generating lottery numbers (from 1-49)
              for ( n = 0; n < 49; n++ ) {
                   loto[n] = (int)(Math.random() * 49 + 1);
                   System.out.println(loto[n]);
              for ( p = 0; p < loto.length; p++ ) {
                   for ( s = 0; s < loto.length; s++ ) {
                        if ( loto[p] == loto[s] ) {
                             x++;
                             System.out.println(loto[p]
                                              + " ocorre " + x + " vezes");// prints nonsenses
    }looks like (inside the if) i'm comparing every array element to all the others and then counting each repetition...
    can someone sort me out of this, or at least give me an hint? (pls dont ask for interfaces)

    I did it!
    // Generate lottery numbers (from 1-49)
    // Print number of occurrences of each number
    public class Lotaria {
         public static void main(String[] args) {
              int x = 0;
              int p = 1;
              int s = 1;
              int n = 1;
              int[] loto = new int[49];
              // Generating lottery numbers (from 1-49)
              for ( n = 0; n < 49; n++ ) {
                   loto[n] = (int)(Math.random() * 49 + 1);
                   System.out.println(loto[n]);
              for ( p = 0; p < loto.length; p++ ) {
                   for ( s = 0; s < loto.length; s++ ) {
                        if ( loto[p] == loto[s] ) {
                        x++;
              System.out.println(loto[p] + " ocorre " + x + " vezes");
              x = 0;
    }i think the 3rd loop (my original idea) can be more elegant but right now i cant cope with it
    the secret was in resetting "x"!...
    thanks to both for helping me

  • Comparable array

    Hi,
    point of intrest as was looking in a book and one of the excercises was to make a generic storage array
    if I have the following
    private Comparable[]  list; and want to add and sort generic objects to this is there anyway I can use either Collections.sort or Arrays.sort, without implementing comparable (I know how to do it this way fine ie having two objects over riding compareTo)
    Am I missing a trick?
    Thanks in advance
    .

    You can use Collections.sort and Arrays.sort with a
    Comparator. Then you don't have to implement
    Comparable.Good point. But it'd be tough to write a Comparator for a "generic" object. If you wanted to compare hash codes or string values it'd be okay, I guess...

  • Compare Array

    I need to compare 2 array tokens to see if they are the same or not.
                if //insert missing code here
                    // Destination identical to origin.
                    error = true;
                    System.err.println("Destination identical to origin. - " + line);
                }The two array tokens are tokens[2] and tokens[3]
    Do you need to use something like "compareTo" or something?? I tried using "if (tokens[2] == tokens[3])" but it still won't work.
    HALP!!!

    It is explained at the method description at the java.lang.String API: http://java.sun.com/javase/6/docs/api/java/lang/String.html

  • Compare Array in Conbination

    How to compare two arrays and find same combinations?

    The correct function to use in column E to solve this problem is dependent on the data that will be in columns F-H. I assumed those columns would contain numbers between 0 and 999999
    Formula in E2 =IF(ISERROR(MATCH(A$2,F2:H2,0)+MATCH(B$2,F2:H2,0)+MATCH(C$2,F2:H2,0)),0,999999)
    Formula in D2 =COUNTIF(E,999999)
    Fill color for A2 through D2 was hand selected, not conditional.
    Conditional format for F2-H2 is "if less than E2 then green fill". Similar conditional format for the remaining rows. If you set this up before putting in the numbers, you can fill the format to the other rows. If you do it later, you can Copy Style/Paste Style to the other rows then change E2 to E3, E4, etc. as you go.

  • Compare array of picture

    Hi all,
    I need some help on these.
    A black and white picture (bmp file) is to be opened and let say that the picture is divided into 4 quarters. If as long as there is a white spot on the top left quarter, the program has to be able to identify it as pattern A.   Likewise if there is a white spot on the top right quarter, the program will identify it as pattern B.
    Please advise and thank you in advance.
    Regards,
    Lip Seng

    Hi,
    It's hard so give a solution without seeing the picture. "Black and white" and "white spots" are open for interpretation. (B&W could be gray, white spots can be different sizes, what is the level of the background noise, how consistent are the picture colors, etc.)
    In the simples case (the spots have high intensity level and are of significant size, background have low intensity level, low bg noise level) I'd try this.
    First, I'd divide the 2d picture data into 4 separate arrays. Then, get a histogram of each array. Get the amplitude of a representative value, and check it against a value. If it is higher, there must be a white spot.
    (Even simpler.. If there is only one pixel against a totally black bg, just use a array max & min, and you instantly have the index of the spot!)
    Regards,
    Wiebe.
    "Lip Seng" <[email protected]> wrote in message news:[email protected]..
    Hi all,
    &nbsp;
    I need some help on these.
    &nbsp;
    A&nbsp;black and white picture (bmp file) is to be opened and let say that the picture is divided into 4 quarters. If as long as there is a white&nbsp;spot on the top left quarter, the&nbsp;program&nbsp;has to be able to identify it as pattern A.&nbsp;&nbsp; Likewise if there is a white&nbsp;spot&nbsp;on the top right quarter, the program will identify it as pattern B.
    &nbsp;
    Please advise and thank you in advance.
    &nbsp;
    &nbsp;
    Regards,
    Lip Seng

  • Comparing Array

    Hello,
    can you plz help me.
    i am checking two array.
    var temItemNo_array:Array = Array(12,13,17,19,20);
    var Item_array:Array = Array(12, 13, 14, 15, 16, 17);
    when checked [B]temItemNo[/B] &&  [B]Item_array[/B] in this arrays 12,13 are same no.
    but when 12 & 13 got continuous common no. that time want stop on 13 no and add on 13+1=14
    Thanks
    JaxNa

    if there are 2 common elements that are adjacent integers then i want next integer
    if 12 & 13 are 2 common element that are adjacent then i want next integer is 14.
    one more example
    if 17& 18 then i want  next integer is 19.
    Thanks a lot kglad

  • How to compare the same array?

    Hello,
    The question not how to compare arrays.
    I have a method that gives results of an array type int.
    for(......){
    int [] arrayFunc(int [] input)
    return arrayOut;
    }I want to compare those arrayOut arrays. I need to find a way to save the first output and then compare it with the newest output. Where do I have to put the temp array to temporary save the array? What should happen if I want to keep track of the results and get comparisons of first, second, third output?
    Thanks

    Still not 100% sure but I try and help. What you need to do is have two references. After you have generated a result compare it to the last result. After the comparison you need to assign the current result to the last result and then go around the loop again to generate a new current result. Below is some code that uses plain ints but I hope it illustrates what I am trying to explain.
    import java.util.Scanner;
    class ComparingNumbers {
      public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int current;
        System.out.print("Number: ");
        int last = scanner.nextInt();
        scanner.nextLine();
        for(int index = 0; index < 10; index++) {
          System.out.print("Number: ");
          current = scanner.nextInt();
          scanner.nextLine();
          System.out.println("Difference is " + Math.abs(current - last));
          last = current;
    }

  • Compare 2 arrays,if same value add the value.If different value show 0

    hello to all! i am new to labview and i'am trying to solve a labview exercise
    ''compare 2 arrays 1d 1x10 (the values of them are lucky numbers from 1 to 10)  .compare them and create a new array [1,10] that saves the same values in the corresponding places ,while in the remainder places where the elements of 2 tables are different  show 0''
    One Example
    In this time of project i have stuck at the comparison of values of two array.and how i would achive creating the Array3! I have search the forum about founding any answer.Any ideas?
    Message Edited by sdadfsdfds on 06-05-2008 12:08 PM
    Message Edited by sdadfsdfds on 06-05-2008 12:09 PM

    I am guessing that since this is a labview exercise it is meant as a learning experience.  There are several ways to solve this problem, I have shown one way below.  I suggest that you try and come up with other ways on your own.  Feel free to ask any questions.
    Cheers
    Message Edited by jmcbee on 06-05-2008 11:25 AM
    CLA, CLED, CTD,CPI, LabVIEW Champion
    Platinum Alliance Partner
    Senior Engineer
    Using LV 2013, 2012
    Don't forget Kudos for Good Answers, and Mark a solution if your problem is solved.
    Attachments:
    Compare Arrays.PNG ‏3 KB

  • Compare two arrays

    I have two arrays such as these
    Array 1                          Array 2
    a      1
    a      5                                 a
    b      2                                 b
    c      3                                 f
    d      4                                 g
    e      5                                 h
    f       6
    g      7
    g      10
    h      8
    h      9/
    with what i have now i can create an array that lists the matching elements
    Results:
    a          1
    b          2
    f           6
    g          7
    h          8
    However, it does not record both sets of a,g, and h, only the first instance. Anyone know how to fix this problem?
    Any help is appreciated
    Solved!
    Go to Solution.
    Attachments:
    Compare Arrays.vi ‏14 KB

    rmarks12 wrote:
    im pretty new to labview.
    That's okay we were all new at some point.  If you have an question about a function in particular you can open the context help (CTRL + H) and over over a function to learn more.  Also here is some free training if you are interested.
    NI Learning Center
    NI Getting Started
    -Hardware Basics
    -LabVEW Basics
    -DAQ Application Tutorials
    3 Hour LabVIEW Introduction
    6 Hour LabVIEW Introduction
    Self Paced training for students
    Self Paced training beginner to advanced, SSP Required
    LabVIEW Wiki on Training
    With questions on anything else, feel free to do what you are already doing, post here on the forums.
    Unofficial Forum Rules and Guidelines - Hooovahh - LabVIEW Overlord
    If 10 out of 10 experts in any field say something is bad, you should probably take their opinion seriously.

  • The arrays class question

    consider the code below
    int[] list = {2, 4, 7, 10};
    java.util.Arrays.fill(list, 7);
    java.util.Arrarys.fill(list, 1, 3, 8);
    System.out.print(java,util.Arrays.equals(list, list));i understand line 2, it gonna fill 7 into the array,so the output would be Line 2: list is {7, 7, 7, 7}
    my question is line 3, how come the output would be {7, 8, 8,7} what does 1 and 3 represent in a arrary?
    the line 4 output would be {7, 8,8,7} again why?
    Thank you guys whoever is gonna take to respond me questions

    zerogpm wrote:
    but which 2 lists were comparing ? since i have list list with the same name1) You're not comparing lists, you're comparing arrays.
    2) You're comparing a single array with itself.
    3) Objects, including arrays, do not have names. Classes, variables, and methods have names. Objects do not.

  • Sorting Arrays in a Vector by a String field in the array

    Hi
    i have a Vector where i put Arrays in. These Arrays are all of the same type. The first field is kind of an indetifier, the type is String. That's the key field i'd like to sort the vector elements in an alphabetical order.
    I know there is that Collator methode to sort Vectors. That's no problem for me to do if i just have Strings in the Vector. But with this contruct of Arrays that need do be sortet for one fiel of the array, i have no idea whether this might be done with that Collator methode too.
    So, before i start written some kind of bubble sort methode (that sure would solve the problem, but probably not very smart and fast...) I'd like to ask you, whether you have an idea how to solve that problem with Collator or even with some other methode?
    thanks for your help!

    Comparable and Arrays.sort. Read the APIs, or look at the two or three examples I've done so far today in this forum. Or search the forum for +Comparable Arrays sort
    Answer provided by Friends of the Water Cooler. Please inform forum admin via the
    'Discuss the JDC Web Site' forum that off-topic threads should be supported.

Maybe you are looking for

  • Camera Raw 8.4 not working in Lightroom 5

    Hi: did install the CR 8.4 Beta. Can now preview .NEF files taken with the Nikon D4S in Photoshop and Bridge, however in Lightroom this is not working. Any idea why this is? Is there a workaround or a solution? Thx

  • Strange sound on retina macbook pro

    This has happend twice now. It first happend a few weeks ago and then tonight. I got into the desktop and went to open a browser and there was the strange sound that almost sounded like an quiz show buzzer when you get the answer wrong. It is a deep

  • Can I watch movies without wifi on my iPod touch.

    Why can't I watch movies on my iPod touch?

  • Web Service (SSL) and certificates (keytool) with INternet Explorer

    Hi, Followed this steps http://www.grallandco.com/blog/archives/2006/10/using_htts_with.html to have a secure SSL WEb service (with client authorization). Tested from Jdeveloper it worked O.K. Now I would like to test it with Internet explorer, but n

  • PS CS6 / Firewire / Issue

    MacBook Pro / 10.8.2 I have now noticed that when my Western Digital external firewire is connected, PS will open an image but most of the options are greyed out. I can't work with the image. When I eject the WD drive, PS works. Has anyone run into t