Comparing elements in 2d array

Hi all
I need a solution. The problem is I have a 2-d array of numbers. I have to display a array subset such that the elements in the first row fall in the ranges provided by me through user prompt.  

04998285626 wrote: 
...The problem is I have a 2-d array of numbers. I have to display a array subset such that the elements in the first row fall in the ranges provided by me through user prompt.  
And...
04998285626 wrote:
its like i have a 2d array of numbers in increasing order. i input a number and i have to get the output array as all the elements that are less than it in the same order.( or rather get a subarray upon comparing the elements )
OK, let's try to interpret this once more in clearer language. Apparently, the first row has some significance.
Maybe only the first row is increasing in value and we want to keep the subset of the 2D containing all columns that are below a threshold in the first element. Since the values in the first row are increasing, all we need to do is find the column index where the first element is too big, and then take the subset of the 2D array up to this point. Here is a solution for this interpretation of the task.
You still might need to adjust for detail, e.g. use "greater or equal?" instead of "greater?" depending on your exact needs.
Message Edited by altenbach on 08-23-2008 11:19 AM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Trim2DArray.png ‏28 KB

Similar Messages

  • Failed to compare two elements in the array

    very often, I have the error "Failed to compare two elements in the array" in Exchange 2013 ECP. We are not running DAG. I google a bit but don't get a lot of result on this.
    I was trying to track mail from a user who send to DL group. Since I can't do in in ECP , how can I do it in EMS?

    I too have this issue.  I'm not sure how wide spread.  I know of one user who sends emails regularly to a DL named "All Users" which is a Security Group which we then add real users to and not just every mailbox.  When he sends the emails,
    from his perspective, everything is fine, meaning he gets to NDR or anything.  Also, when he adds the Dl in Outlook To field and expands it, all the correct users are there.  In fact, it tells him there are 203 addresses here.  However, only
    184 are actually getting the message.  When I try the EAC to view the tracking report, it will show the message, but if I click on the edit button, I get "Failed to compare two elements in the array".  If I try from EMC with search-messagetrackingreport
    -identity "recipient address" -sender "sender address" -bypassdelegatechecking and the recipient address is the group, it says it could not be found.  If I try with simply putting an email address of someone who is a member of that group, it says Warning:
    An unexpected error has occured and a Watson dump is being generated.  Failed to compare two elements in the array.  I don't know what else to try.  Anybody??

  • Is there a way of determining what element in an array is being clicked on?

    Hi all.  I would like to setup an event to determine what element in an array is being clicked on/hovered over.  I think I tried this before and found it wasn't working due to limitations of LV 7.0.  If this code already exists, it would be great if I don't have to do a scavenger hunt for the solution.
    I think one possibility I nixed was to use the refnum of the elements to determine which one it is.  IIRC, this is not possible because the refnum of the element is for the edit box only.
    The second possiblity is to get the on click event, and somehow determine which element in the array it is.  This doesn't sound too difficult as it should be a simple calculation, but may get in to some hairryness based on if the indicies are visible or not, and if I am using a new or old array with new or old control (calc would change based on boarder size of the controls).  I might just simplify it by removing indicies and using older control set which has minimal boarder size.
    And just for fun, can I force a tool tip to show up?
    Thanks all,
    A
    Using LV7.0 on WinXP.

    blawson wrote:
    Been bitten by LabVIEW wrote:
    I think one possibility I nixed was to use the refnum of the elements to determine which one it is.  IIRC, this is not possible because the refnum of the element is for the edit box only.
    Using LV7.0 on WinXP.
    This is indeed possible, at least in the newer versions I use.
    Take the array refnum from the click event data terminal and get a reference to the array element.  This refers to the element that was clicked, but you do need to work out how to get the index.  My method is to use property nodes to get the screen position and size of the element and the screen position and size of the array, as well as the array's Visible Index property. For each direction, take the quotient of the relative position of the element (account for padding!) over the size of an element.
    I suspect that taking the mouse coords and comparing to the array's sizes in pixels is similar, although I trust my method for events that don't have mouseclicks (what coords does Array:shortcut menu selection(User) return if you used the keyboard?)
    Here's an old version I happened to have open.  I've posted about this before, I suspect I have a clearer version in my gallery.  I use this method in my example code contest entry to work out which square of the chessboard is clicked.
    Thank you for that one!
    I am currently "locked up behind a down-rev fence" (working an old app in an old version) so I had not heard of that.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • Sort an an arrayList by the first element of an array

    Hi,
    I am really struggling trying to sort an arratList of arrays. I have an arrayList
    ArrayList<String[]> myArrayList = new ArrayList<String []>(100);
    Within this array I have may arrays with 2 elements
    String[] myArray1 = {"Peter", "London"};
    String[] myArray2 = {"John", "London"};
    String[] myArray3 = {"Tony", "Birmingham"};
    I add all these arrays to the arrayList and want to sort by the first element of the array. Basically I expect the final arrayList to be in the order of:
    "John", "London"
    "Peter", "London"
    "Tony", "London"
    Thanks
    Peter

    Hi,
    I am really struggling trying to sort an arratList of
    arrays. I have an arrayList
    ArrayList<String[]> myArrayList = new
    ArrayList<String []>(100);
    Within this array I have may arrays with 2 elements
    String[] myArray1 = {"Peter", "London"};
    String[] myArray2 = {"John", "London"};
    String[] myArray3 = {"Tony", "Birmingham"};
    I add all these arrays to the arrayList and want to
    sort by the first element of the array. Basically I
    expect the final arrayList to be in the order of:
    "John", "London"
    "Peter", "London"
    "Tony", "London"
    Thanks
    PeterThis can be done by using
    Collections.sort(myArrayList, new Comparator<String[]>() {
    public int compare(String[] s1, String[] s2) {
    if (s1.length() <1) {
    return -1;
    if (s2.length() <1) {
    return 1;
    return s1[0].compareTo(s2[0]);
    });

  • Can;t find what is wrong. Trying to add elements in two arrays

    Hello everyone
    I'm trying to take as input two numbers, convert them to arrays and add all the element of the array one by one. I want the result to be the sum of every element of the array. Let's say array1={1,2,3,4} and array2={2,6,4,3} I want the final result to be 3877.
    If the sum of one element of the array is greater than nine, then I would put zero and add 1 to the element on the left.
    Here is the code:
    import javax.swing.JOptionPane;
    public class Main {
        public static void main(String[] args) {
            String numberOne = JOptionPane.showInputDialog
                                    ("Enter the first number: ");
         String numberTwo = JOptionPane.showInputDialog
                                    ("Enter the second number: ");
            //compare string length and make them equal length
            int[]n1 = toArray(numberOne); // my first array
         int[]n2 = toArray(numberTwo); // my second array
         //call the method that ads both strings
         int[]finalArray = arrSum(n1,n2);
           JOptionPane.showMessageDialog(null, "The sum of the two numbers is: "
                   + finalArray);
        }//end of main
        //method to create an array from a string
        public static int[] toArray(String str)
                int[]arr = new int[str.length()];
                arr[0]=0;
                for (int i=1; i<str.length(); i++)
              arr= Character.digit(str.charAt(i),10);
    return arr;
    }//end of toArray
    //method to add arrays by elements
    public static int[]arrSum (int[]arr1, int[]arr2){
    for (int i = arr1.length-1; i >=1; i--)
    int sum = arr1[i] + arr2[i];
    if (sum > 9)
              { sum -= 10;
              arr1[i-1]++;
    return arr1;
    }//end of arrSum method
    }Edited by: designbc01 on Feb 16, 2010 1:15 AM                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    The best advice I can give you is to break your problem up into smaller pieces. First, focus on a method that converts an input String into an array. When you have that working perfectly, then focus on creating a method that "adds" two arrays with the logic you described. When you have that working perfectly, then combine the two different pieces.
    Why does your for loop in toArray( ) start with 1? The first index of a String, array, or pretty much anything else, is zero.

  • Comparing elements inside a vector

    Hello,
    I am having a hard time understanding how to compare elements inside a vector. I have a vector of six strings and I want to compare the first element at index 0 with all other elements at positions 1-5. After that, compare the element at position 1 with elements at positions 2-5 and so on until all elements have been compared against each other.
    Can some one please advise me on how to achieve this?
    Thank you.

    joor_empire wrote:
    Thanks for replying. I tried using nested loops, but I keep getting array index out of bound error.Hmmm, then you're doing it wrong.
    For more information, you'll have to give us more info, such as your code (please use code tags when posting it though).

  • How to compare 1000 X 512 arrays

    Hello there,
    I have problem with comparing large amount of arrays. I have 1000 x 512 arrays. That means i have 1000 lines and each line contain 512 elements. I want to compare this 512 elements of each line and short out same one. how can i do? In result i want only the filtered one that means if out of 1000 line if 200 line are same then i want only 800 arrays that means 800 X 512
    Thanx in advance,
    dipen

    Is the 2D array sorted (i.e. are the duplicate rows next to each other)?
    Is the duplicate row always the same or can you have several different rows that are duplicate?
    What is the datatype of the array?
    No matter what, this seems like an easy task. Can you attach a VI containing typical data?
    LabVIEW Champion . Do more with less code and in less time .

  • How do you assign multiple values to a single element in an array?

    I'm probably not wording the question right.
    I have an array, let's call it M[], and for each element in the array (we'll say M[1]), I need assign three integers: row, col and value.
    I need to set it up so I can do something like this:
    A.row = M[i].col;
    A[i].col = M[i].row;
    A[i].value = M[i].value;
    The algorithm isn't what I need help with, it's assigning .col, .row and .value to an index of an array.
    Please help if you can.

    You are right. You did not word your question perfectly, but I still think I get what you want.
    First of all: A single element in an array always has exactly one value. No more, no less.
    But that's not a problem. The element in an array is either of a primitive type (boolean, byte, char, short, int, long, float, double) or it's a reference (to a Object, String, MyClass, ...).
    You can simply write a class that holds your three values and create an array of that type:
    public class SomeData {
      public int row;
      public int col;
      public int value;
    // somewhere else:
    SomeData[] a = new SomeData[10];
    a[0] = new SomeData();
    a[0].row = 10;
    a[0].col = 5;
    a[0].value = 42;Note how you only assign a single value to the element (a[0]) itself. All other assignment actually go to fields of the object refered to by that element in the array.
    Also note that in Java types (such as classes, interfaces, ...) should start with a upper-case letter, while variables (local variables, members, parameters) and method names should start with a lower-case letter.
    Edit: I'm getting old ...

  • How can I change the properties of only one element in an array of booleans?

    I'm displaying an array of booleans to my operators, with each boolean in the array representing some system status check.  Some of these checks are critical and some are not, therefore I want some of these booleans to have a different color when in the TRUE state (Red for the critical ones and Yellow for the non-critical ones).  I can change the boolean colors with a property node, but that effects every element in the array.  Is there any way to change a property of an individual element in an array?  I know that I could take the incoming array and break it into two arrays - one for critical and one for non-critical, but this system is replacing an older system and the operators are accustomed to seeing their indicator lights a certain way and I'm trying to replicate what they had exactly.

    Here's what I had in mind
    Of course you can use as many colors as you want.
    Message Edited by altenbach on 12-21-2005 04:53 PM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    LEDarray.png ‏7 KB
    ColorArray3.vi ‏23 KB

  • In LabVIEW6i, is there a way to make particular elements of an array invisible while the others stay visible (without losing any element's info.)?

    I have an array of clusters. Each cluster pertains to a certain oscilloscope I am controlling. There is another control which specifies which oscilloscopes I have "on".
    If a particular oscilloscope is "on" I want its cluster to be VISIBLE in the array. If a particular oscilloscope is "off" I want its cluster to be INVISIBLE in the array.
    How can I implement this in my program without losing ANY of the info. in my array?

    I suggest to use two arrays; one for user interface holding the ON clusters,
    and one for internal use holding all clusters. The diagram periodically
    updates the internal array with user interface array data.
    By INVISIBLE do you mean "skipped from the array" or displayed as an empty
    placeholder? To hide an OFF cluster you could put in the cluster a flat
    button boolean that is small and transparent when ON and large enough to
    cover the whole cluster area (and other controls) when OFF.
    Jean-Pierre Drolet
    Scientech R&D
    "mcmastal" a écrit dans le message news:
    [email protected]..
    > In LabVIEW6i, is there a way to make particular elements of an array
    > invisible while the others stay visible (without losing any element's
    > info.)?
    >
    > I have an array of clusters. Each cluster pertains to a certain
    > oscilloscope I am controlling. There is another control which
    > specifies which oscilloscopes I have "on".
    > If a particular oscilloscope is "on" I want its cluster to be VISIBLE
    > in the array. If a particular oscilloscope is "off" I want its
    > cluster to be INVISIBLE in the array.
    > How can I implement this in my program without losing ANY of the
    > info. in my array?
    LabVIEW, C'est LabVIEW

  • How to highlight a specific element of an array

    I'm having some trouble selecting which element in an array has key focus. I want to be able to selectively highlight individual elements in an array of strings and set the key focus so that the user can immediately enter the text into that specific element.
    I have been able to get "selection.start" and "selection.end" to work, but when I get a reference to "array element" it always returns a reference to the last element manually clicked. This way, I can only programatically highlight different elements by manually clicking on them, which somewhat defeats the purpose.
    Does anyone know if this is possible, or if I need to move to tables or something else in order to give me this functionality?
    I'm using LV 6.1
    on W2k.
    Thanks
    Shane.
    Using LV 6.1 and 8.2.1 on W2k (SP4) and WXP (SP2)

    I had the problem that I would like to highlight more than one cell in a 2d array.
    multicolumn listbox is very slow working with large data volumes so I had to use a 2d array instead, but then I lose the possibility to highlight.
    The solution I used was to bundle a LAD and control an put this in the array, takes a bit more coding but works fine. 
    Attachments:
    2d array with marker.vi ‏23 KB

  • How to pass a single element in an array to XSL from BPEL

    In a bpel (2.0) process I have a for-each loop iterating through a list in the original input document.  Within that loop I need to construct an  input document  for a call to a web service based on data in the current node of the list objects I am looping through.
    Constructing the input document via BPEL assign activity copies within the for-each loop is an option but due to the complexity of that document I would prefer to use XSL.  But I don't know how to pass the index information (ie. the for-each counter) into XSL and use it there (and I would prefer not to have to do so, since that will prevent use of the XSL GUI in jdev), so I would prefer to send  the current node of the list as input to XSL instead.
    Is it possible to pass a sub-section of an XML document (e.g. one node in the array) as input into XSL rather than the whole document?  In other words, I would like to send the current array element from the original input document rather than the entire original input document because I will be using the data within that array element to create the web service input document.
    Example:
    <forEach parallel="no" counterName="i"
                         name="ForEachEntry">
                  <startCounterValue>1</startCounterValue>
                  <finalCounterValue>$numTimeEntries</finalCounterValue>
    If I used the BPEL assign activity to populate the input document I would need lots of copies similar to this:
                  <copy>
                      <from>$inputVariable.OteStgTimecardCollection/ns3:OteStgTimecard[1]/ns3:oteStgTimecardDetailCollection/ns3:OteStgTimecardDetail[$i]/ns3:origtransactionreference</from>
                      <to>$InvokeOteDetailAbsenceErrorStatusService_OteAbsenceDetailFailureService_InputVariable.OteAbsenceDetailFailureServiceInput_msg/ns19:OrigTransactionReference</to>
                  </copy>
    I would prefer to send the current list object as an input variable into an XSL transform: 
         $inputVariable.OteStgTimecardCollection/ns3:OteStgTimecard[1]/ns3:oteStgTimecardDetailCollection/ns3:OteStgTimecardDetail[$i]
    Is there syntax in bpel that would do that?
    Thanks

    You need use While Element and use Array like Element[number]
    With While element you iterate <employee> node
    and with Element[number] you can extract information from that node.
    I wrote a BPEL that scan a XML file, the input is:
    <cliente>
            <codigo>01</codigo>
            <nombre>Deiby Mauricio Gomez</nombre>
                    <productos>
                            <producto>
                                    <nombre>Camisa Polo</nombre>
                                    <precio>50</precio>
                            </producto>
                            <producto>
                                    <nombre>Pantalon Lona</nombre>
                                    <precio>100</precio>
                            </producto>
                    </productos>
            </cliente>
            <cliente>
            <codigo>02</codigo>
            <nombre>Julio Cesar Ayapan</nombre>
                    <productos>
                            <producto>
                                    <nombre>Camisa Polo</nombre>
                                    <precio>50</precio>
                            </producto>
                    </productos>
            </cliente>
    In my BPEL I added up all article prices and after that I write to txt file the client and the Total.
    Example:
    Deiby Gomez, 150
    Cesar Ayapan, 50
    My while element is this (Please pay attention in bold words):
      <while name="While1"
               condition="bpws:getVariableData('variable1')&lt;=count(bpws:getVariableData('Receive1_input_files','body','/ns4:clientes/ns4:cliente'))">
          <sequence>
            <assign name="Assign1">
              <copy>
                <from expression="sum(bpws:getVariableData('Receive1_input_files','body','/ns4:clientes/ns4:cliente[number(bpws:getVariableData(&quot;variable1&quot;))]/ns4:productos/ns4:producto/ns4:precio'))"/>
                <to variable="Invoke1_process_InputVariable" part="payload"
                    query="/ns5:process/ns5:cantidad"/>
              </copy>
              <copy>
                <from variable="Receive1_input_files" part="body"
                      query='/ns4:clientes/ns4:cliente[number(bpws:getVariableData("variable1"))]/ns4:codigo'/>
                <to variable="Invoke1_process_InputVariable" part="payload"
                    query="/ns5:process/ns5:id"/>
              </copy>
            </assign>
            <invoke name="Invoke1" inputVariable="Invoke1_process_InputVariable"
                    outputVariable="Invoke1_process_OutputVariable"
                    partnerLink="ValidacionBancos2WS" portType="ns5:BPELProcess1"
                    operation="process" bpelx:invokeAsDetail="no"/>
            <switch name="Switch1">
              <case condition="bpws:getVariableData('Invoke1_process_OutputVariable','payload','/ns5:processResponse/ns5:resultado')='true'">
                <bpelx:annotation>
                  <bpelx:pattern>Si el cliente es aprobado</bpelx:pattern>
                  <bpelx:general>
                    <bpelx:property name="userLabel">Si Aprobado</bpelx:property>
                  </bpelx:general>
                </bpelx:annotation>
                <sequence>
                  <assign name="Assign4">
                    <copy>
                      <from variable="Receive1_input_files" part="body"
                            query='/ns4:clientes/ns4:cliente[number(bpws:getVariableData("variable1"))]/ns4:codigo'/>
                      <to variable="Approved_Write_input" part="body"
                          query="/ns7:clientes/ns7:cliente/ns7:id"/>
                    </copy>
                    <copy>
                      <from variable="Receive1_input_files" part="body"
                            query="/ns4:clientes/ns4:cliente[number(bpws:getVariableData(&quot;variable1&quot;))]/ns4:nombre"/>
                      <to variable="Approved_Write_input" part="body"
                          query="/ns7:clientes/ns7:cliente/ns7:nombre"/>
                    </copy>
                    <copy>
                      <from expression="sum(bpws:getVariableData('Receive1_input_files','body','/ns4:clientes/ns4:cliente[number(bpws:getVariableData(&quot;variable1&quot;))]/ns4:productos/ns4:producto/ns4:precio'))"/>
                      <to variable="Approved_Write_input" part="body"
                          query="/ns7:clientes/ns7:cliente/ns7:total"/>
                    </copy>
                  </assign>
                  <invoke name="Invoke2" inputVariable="Approved_Write_input"
                          partnerLink="fileAdapterWriteApproved"
                          portType="ns6:Write_ptt" operation="Write"
                          bpelx:invokeAsDetail="no"/>
                </sequence>
              </case>
              <otherwise>
                <sequence name="Sequence1">
                  <assign name="Assign5">
                    <copy>
                      <from variable="Receive1_input_files" part="body"
                            query='/ns4:clientes/ns4:cliente[number(bpws:getVariableData("variable1"))]/ns4:codigo'/>
                      <to variable="Rechazados_Write_input" part="body"
                          query="/ns9:clientes/ns9:cliente/ns9:id"/>
                    </copy>
                    <copy>
                      <from variable="Receive1_input_files" part="body"
                            query="/ns4:clientes/ns4:cliente[number(bpws:getVariableData(&quot;variable1&quot;))]/ns4:nombre"/>
                      <to variable="Rechazados_Write_input" part="body"
                          query="/ns9:clientes/ns9:cliente/ns9:nombre"/>
                    </copy>
                    <copy>
                      <from expression="sum(bpws:getVariableData('Receive1_input_files','body','/ns4:clientes/ns4:cliente[number(bpws:getVariableData(&quot;variable1&quot;))]/ns4:productos/ns4:producto/ns4:precio'))"/>
                      <to variable="Rechazados_Write_input" part="body"
                          query="/ns9:clientes/ns9:cliente/ns9:total"/>
                    </copy>
                  </assign>
                  <invoke name="Invoke3"
                          inputVariable="Rechazados_Write_input"
                          partnerLink="fileAdapterWriteRechazados"
                          portType="ns8:Write_ptt" operation="Write"
                          bpelx:invokeAsDetail="no"/>
                </sequence>
              </otherwise>
            </switch>
            <assign name="Assign2">
              <copy>
                <from expression="''"/>
                <to variable="Invoke1_process_InputVariable" part="payload"
                    query="/ns5:process/ns5:id"/>
              </copy>
              <copy>
                <from expression="bpws:getVariableData('variable1')+1"/>
                <to variable="variable1"/>
              </copy>
              <copy>
                <from expression="''"/>
                <to variable="Invoke1_process_InputVariable" part="payload"
                    query="/ns5:process/ns5:cantidad"/>
              </copy>
            </assign>
          </sequence>
        </while>

  • How can I change all Inf elements in an array to a specific value?

    I would like to change all Inf elements in my array to -1. Basically, I am looking for something similar to the range and coerce function, except that I want all values above a certain value to be a specific negative value, rather than go to that value.
    I could use a case structure and go through each element in the array, but I am hoping to find something more efficient.Any ideas?
    Solved!
    Go to Solution.

    P@Anand wrote:
    I would do that in this way.
    Here's a simpler version...
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines
    Attachments:
    Replace in Array.png ‏4 KB

  • I want to create an array that goes into a case structure where each element in the array is an individual case and gets done in order

    I want to create an array that goes into a case structure where each element in the array is an individual case and gets done in order. Any ideas, I've been playing with the idea but have had no luck, is this even possible?

    Hi,
    Please check it out the attached Vi.. Is this you need?
    Sasi.
    Certified LabVIEW Associate Developer
    If you can DREAM it, You can DO it - Walt Disney
    Attachments:
    Event.vi ‏11 KB

  • How to change the properties of individulal elements in an array?

    Hi all,
    I have an array (size is 25) of string and I want to disable and grayout half of them. But how do I do it? How do I change the properties of individual elements in an array? I have tried to use some of the examples given in the discussion forums, but it didint work for the task mentioned above. Anybody would be able to help me with a suitable example that can be specifically used for disable or enable the individual array  elements?
    Dev

    Telemaque wrote:
    The user will see the first half of the string elements filled-in and the lower half grayed-out (to be filled in later).  Make a test VI, play around.
    ... except that all elements "greyed out" with this method contain the default string for the array element (blank by default, but changeable). There is no way to have meaningful, unique text in the greyed out elements.
    I would suggest to use a listbox as control/indicator. Here elements can easily be disabled programmatically.
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for