Getting row and column of an array element

Hi,
I have an array of 24 rows and 24 column giving me a total of 576 elements. How do I get the row and column of a particular element in an array in LabView. E.g. If I have to write to element 127 how do I get the column and row in which element 127 is located.
Regards,
Harshil
Solved!
Go to Solution.

Hi Harshil,
maybe you only need to find the correct "address" of the element in your 2D array?
Use something like this:
Maybe you have to switch Row&Column output according to your numbering scheme...
Best regards,
GerdW
CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
Kudos are welcome

Similar Messages

  • Remove specific row and column from 2d array

    Hi,
    I would like to know how to remove the specific row and column from 2d array.
    for example, I have the original 4x4 array as below
    2 -1 -1 0
    -1 2 0 -1
    -1 -1 2 0
    -1 -1 -1 3
    let say that i want to remove row 2(bold) and column 2(bold), and the new 2d array should get as below
    2 -1 0
    -1 2 -1
    -1 -1 3
    Thanks.

    You can't remove elements of an array, it's fixed at a certain size once created. What you can do however is make a new array and only copy the things you want. Something like:public static void main(String[] args) {
        Integer[][] bar = new Integer[5][5];
        for (int i = 0; i < bar.length; i++) {
            Integer[] baz = bar;
    Arrays.fill(baz, i);
    System.out.println(Arrays.toString(baz));
    Integer[][] muu = new Integer[5][4];
    removeColumn(3, bar, muu);
    for (Integer[] mee : muu) {
    System.out.println(Arrays.toString(mee));
    Integer[][] smuu = new Integer[4][5];
    removeRow(3, bar, smuu);
    for (Integer[] mee : smuu) {
    System.out.println(Arrays.toString(mee));
    public static <T> void removeRow(int row, T[][] a, T[][] result) {
    if (row >= a.length) {
    throw new IllegalArgumentException("no row at " + row);
    for (int a_r = 0, result_r = 0; a_r < a.length; a_r++) {
    if (a_r == row) {
    continue;
    System.arraycopy(a[a_r], 0, result[result_r], 0, a[a_r].length);
    result_r++;
    public static <T> void removeColumn(int col, T[][] a, T[][] result) {
    for (int i = 0; i < a.length; i++) {
    if (col >= a[i].length) {
    throw new IllegalArgumentException("no column at [" + i + ", " + col + "]");
    for (int a_i = 0, r_i = 0; a_i < a[i].length; a_i++) {
    if (a_i == col) {
    continue;
    result[i][r_i] = a[i][a_i];
    r_i++;

  • Get the intersection when u know row and column in 2D array

    I am trying to get the intersection of the row and column and I am not able to do so......
    for example:
    123456789 <<These in array indicate the row
    255555555
    388888888
    499997999
    1234 above first element of each row represent columns........
    I want to get 7 which is the intersection of column 6 and row 4............Please help

    Hi Marlin..
    I am reading this after having done it in a very similar way....... thank you so much
    The problem is that the letters in languages can also be characters so they can be a,b..Language over{a,b}..if characters are not in numbers I am trying convert a,b into int internally however I dont know any data structure in java which will accept character as key and int as value......
    So I am stuck at modifying the part highlighted with ???? below
         public void startRecognizing()
              System.out.println("Begun recognizing language....");
              //Convert the word entered to letter array
              char [] wordEntered = word.toCharArray();
              // initialize variables
              currentState = startState[0]; //In the beginning the current state is start state
              /***************    For each letter entered    ********************************/
                   for (int w =0; w < wordEntered.length ;w++)
                        //Print element entered
                        currentChar = wordEntered[w];
                        System.out.println("Char "+currentChar);
                        //Convert to int
                        int currentIntChar;
                        //System.out.println("Char "+currentIntChar);
                        //Print current state
                   int currentIntState = Character.getNumericValue(currentState);
                        //System.out.println(" State "+currentIntState);
                        System.out.println(" State "+currentState);
                   // if characters are numbers this is fine below
                   if((Character.getNumericValue(currentChar)) != -1)
                                          currentIntChar = Character.getNumericValue(currentChar);
    /*** Get the new state based on element entered with the current state and get a new state***/ // column/char entered & row/state// The intersection is the new state which is made the current state for further process
                        //We add 1 since array starts from 0
                   currentState = transitionTable[currentIntState+1][currentIntChar+1];
                        System.out.println("  NEW current state "+currentState);
                   else
         //if letters in the language are not in numbers and are char ie a,b then convert a,b into int internally
                        java.util.Hashtable h = new java.util.Hashtable();
                        // STUCK HERE !!******************??????????
                        h.put(wordEntered[w], new Integer(w));
                        currentIntChar = ((Integer)h.get(wordEntered[w])).intValue();
              System.out.println("currentIntChar non numbers "+currentIntChar);
                        //We add 1 since array starts from 0
                   currentState = transitionTable[currentIntState+1][currentIntChar+1];
                        System.out.println("  NEW current state "+currentState);
              }//for main          
              finalDecision();
         }//startRecognizingThe assignment is due tomm morning...... I havent slept all night !

  • Get Row and Column info from an Array Cluster

    I have an array with a cluster of 2 elements (string and double). Within my application, I am using the State Machine architecture with an Event Structure. When I click on a element within the cluster array, is there a way to retrieve the row and column? I seen the Coordinates within the Mouse Down event but I don't think that will work.
    Any ideas?
    Solved!
    Go to Solution.

    How To Return the Index of a Mouse-Select Array Element:
    https://decibel.ni.com/content/docs/DOC-6406
    Jean-Marc
    LV2009 and LV2013
    Free PDF Report with iTextSharp

  • Summing the Rows and Columns in an Array

    I am importing a 2-dimensional array of integers.(which is held in a 2-dimensional array)
    I need to store the row sums and column sums in separate 1-dimensional arrays.
    I can get the integers in and print out a list along with the grand total(sum of all).
    But, how do I pass each row's and each column's value in to my sumRow and sumCol methods to get the sum for each row and each column?
    Can I do the row and column summing in the same "for" statement where I calculate the "grand total"? Or am I making this more difficult than it is?
    Would appreciate any help.
    This is what I have so far:
    import java.awt.Graphics;
    import java.applet.Applet;
    public class TwoWayTable extends Applet {
         int numRows;
         int numCols;
         int [] [] cell;
         int [] rowSum;
         int [] colSum;
         int grandTotal;
    public TwoWayTable(int [][] data){
    grandTotal = 0;
    cell = new int [data.length][data.length];
    for(int i = 0; i < data.length; i++)
    for(int j = 0; j < data.length; j++){
         cell[i][j] = data[i][j];
    grandTotal += cell[i][j];
         System.out.println(cell[i][j]);
    System.out.println(grandTotal);
    public int sumRow(int [] data2){
         int rowaccumulator=0;
         rowSum = new int[data2.length];
         for(int numRows = 0; numRows < rowSum.length; numRows++){
         rowaccumulator += rowaccumulator + rowSum[numRows];
              return(rowaccumulator);
    public int sumCol(int [] data3){
         int colaccumulator = 0;
         colSum = new int[data3.length];
         for(int numCols = 0; numCols < colSum.length; numCols++){
              colaccumulator += colaccumulator + colSum[numCols];
              return(colaccumulator);

    Thanks for your input.
    I'll make the changes that you suggest.(after this)
    My output prints:
    4 6 3 8 21
    9 1 5 3 18
    13 7 8 11 39
    numbers are right, but I need to format the table
    the output needs to look like this:
    int int int int | rowsum
    int int int int | rowsum
    colsum colsum colsum colsum | total
    How do I do this?
    I have no idea?
    I'm supposed to call a "void setMargins( )" method to line this up, without
    using the exotic formatting in the IO library.
    I'm also supposed to use "public String toString( )"
    This is what I have so far:
    import java.awt.Graphics;
    import java.applet.Applet;
    public class TwoWayTable extends Applet {
    int numRows;
         int numCols;
         int [] [] cell;
         int [] rowSum;
         int [] colSum;
         int grandTotal;
    public TwoWayTable(int [][] data){
    cell = new int [data.length][data.length];     
    for(int i = 0; i < data.length; i++){
    for(int j = 0; j < data.length; j++){
         cell[i][j] = data[i][j];
    calcTotals(cell);
    for(int i = 0; i < cell.length; ++i){
    for(int j = 0; j < cell.length; ++j){
    System.out.print(cell[i][j] + " ");
    System.out.println(rowSum[i] + " ");
    for(int j = 0; j < cell.length-1; ++j){
    System.out.print(colSum[j] + " ");
    System.out.println(colSum[cell.length-1] + " " + (grandTotal));
         public void calcTotals(int [][] data2){
              grandTotal = 0;
              rowSum = new int[data2.length];                         
              colSum = new int[data2.length];                         
              for(int numRows = 0; numRows < data2.length; numRows++){
              for(int numCols = 0; numCols < data2.length; numCols++){
                   grandTotal += data2[numRows][numCols];               
                   rowSum[numRows] += data2[numRows][numCols];
                   colSum[numCols] += data2[numRows][numCols];

  • Getting Row and Column in ADF RC

    Hi,
    I have an ADF RC form with a table control on it. I need to find the row and column of the cell where the user has clicked. I am able to get the row using getSelectedRow() but am not able to get the column of the cell. Could anyone please help?
    Thanks & Regards,
    Mike

    Hi Frank,
    I need the coordinates. eg. My table is something like this
    Country Region City Value1 Value2 Value3 Total
    AAAAA BBBBB XXX 10 15 30 55
    EEEEE YYY 5 2 15 22
    TOTAL 15 17 45 77
    etc.
    If the user clicks on any cell in the country column he can add countries, if he clicks on any cell in the region column, he can add regions. The behavior changes for value1, value2, value3... if he clicks in any of these columns he can add value4, value5 columns. If he clicks on the actual data, he gets another screen.
    Thanks & Regards,
    Mike

  • Getting Row and Column Identifiers to Show

    Does anyone know how to get the row (A,B,C...) and column (1,2,3...) identifiers to show in a Numbers spreadsheet? These are visible on the Mac version but are not visible on iPad version. It seems to me to be a pretty basic spreadsheet feature to easily see how many rows are in the sheet.

    Hi,
    Might be an answer here for you.
    Numbers for iPad: Frequently Asked Questions (FAQ)
    Carolyn

  • Get Row and Column Id of table..

    Hi All,
    I have a table with number of columns having Link UI element. Can anyone have idea that how will I get a row ID/ Column ID, if I select any Link2Action UI element on any Row column.
    Thanks,
    Sanket Sethi

    Hi,
    I guess you want to read the column (ie text value) of Link to Action UI. Check this link for reference: [Link to Action in Table|http://www.zbalai.com/_abap/content/190_Web_Dynpro_Table_Link/web_dynpro_table_link.html]
    Hope this helps u.,
    Thanks & Regards,
    Kiran.

  • I would like to place an element into a two dimensional array, and I would like to be able to specify which row and column each of the elements will go in.

    In the vi that I am writing I have rise and fall times to post in a very specific pattern. I can initialize an array,and I can replace elements, but in "replace element" I only find that I am given the choice of specifying a single dimensional position. I need to be able to specify BOTH column and row. Can anyone help me?

    Hi Jryan !
    If you wire a 2D array to the input of a "replace element" function, you will see that the function expand to display an additionnal index. The one you are looking for !!
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        

  • InDesign Tables: Row and Column Strokes

    Using InDesign Tables: How do you get row and column strokes in a table to appear perfectly joined? When I choose "Column Strokes in Front" (Under Table Setup) i still see a tiny row stroke, and vice versus.. it's really visible in the PDF almost can't see it in InDesign though you can a little...any advice?

    http://lawrence.ecorp.net/inet/samples/dhtml-rollover-tble-cols-rows.shtml

  • I need to take elements from within 2 nested for loops and place them in an array at the specific row and column that I need.

    I have tried intializing an array and replacing elements by specifying a particular row, and column, but in the end I get an array with only one element replaced, and I suspect that it is because as the for loops are running through their iterations each time the array is re-initializing. I have a simple vi that I will post below, it is not the exact situation that I have but is a good place for me to get some understanding. I have the row and column indexes being driven by the inner and outer loop iterations, which gives me the pattern I need. I am using the inner iterations as array elements. How do I set this up so that it works and d
    oes keep re-initializing my array.
    Attachments:
    Untitled.vi ‏26 KB

    I have fixed a number of things in your vi.
    You were right in thinking that the array was continuously re-initialized. To avoid this, use a shift register (right-click the loop border), which will pass the updated array into the next iteration.
    Chilly Charly    (aka CC)
             E-List Master - Kudos glutton - Press the yellow button on the left...        
    Attachments:
    your_vi.vi.zip ‏13 KB

  • How to get number of rows and columns in a two dimensional array ?

    Hello,
    What would be the simplest way to get number of rows and columns in a two dimensional array represented as integers ?
    I'm looking for another solution as For...Each loop in case of large arrays.
    Regards,
    Petri

    Hi Petri,
    See a attached txt file for obtaining two arrays with upper and lower index values
    Regards
    Ray
    Regards
    Ray Farmer
    Attachments:
    Get2DArrayIndex.txt ‏2 KB

  • Hi, how can i break the value for a row and column once i have converted the image to the array?????​??

    Hi, I would like to know how can i break the value for a row and column once i have converted the image to the array. I wanted to make some modification on the element of the array at a certain position. how can i do that?
    At the moment (as per attachhment), the value of the new row and column will be inserted by the user. But now, I want to do some coding that will automatically insert the new value of the row and the column ( I will use the formula node for the programming). But the question now, I don't know how to split the row and the column. Is it the value of i in the 'for loop'? I've  tried to link the 'i' to the input of the 'replace subset array icon' , but i'm unable to do it as i got some error.
    Please help me!
    For your information, I'm using LABView 7.0.

    Hi,
    Thanks for your reply.Sorry for the confusion.
    I manage to change the array element by changing the row and column value. But, what i want is to allow the program to change the array element at a specified row and column value, where the new value is generated automatically by the program.
    Atatched is the diagram. I've detailed out the program . you may refer to the comments in the formula node. There are 2 arrays going into the loop. If a >3, then the program will switch to b, where if b =0, then the program will check on the value of the next element which is in the same row with b but in the next column. But if b =45, another set of checking will be done at a dufferent value of row and column.
    I hope that I have made the problem clear. Sorry if it is still confusing.
    Hope you can help me. Thank you!!!!
    Attachments:
    arrayrowncolumn2.JPG ‏64 KB

  • Arrays[][] - row and column

    Evening All...
    Just a quick question regarding arrays. My program is working but I am trying to tidy it up.
    public class Arrays{
    static int firstArray[][]= new int [][] {{8,5},{9,3}};
    static int secondArray[][]= new int [][] {{1,7},{4,8}};
    static int thirdArray[][]= new int [][] {{0,2,4},{9,6,8}};
         static int fourthArray[][]= new int [][] {{2,1,0},{6,2,3}};
    public static void main(String[] args)
         multiply(secondArray,firstArray);
         multiply(firstArray,thirdArray);
         public static void multiply( int[][] x, int[][] z)
         int array2[][] = new int [3][3];
         int 1r = x.length;
         int 1c = x[0].length;
         int 2r = z.length;
         int 2c = z[0].length;
         //for(etc...)
    //      (Rest of program)
    I want to edit the array.--------int array2[] = new int[3][3]; (up 9 lines)
    Instead of specifying it as [3][3] for size.
    I would like to say new int - length of row and column - im pretty sure it is similar to
    the ints below - but cant seem to get the correct combination.
    Thanks in advance for any help folks.

    - you can use variables to specify array dimensions
    - you can get the (1D) dimension of an array by using the "attribute" theArray.length . Knowing that a 2D-array is indeed an array of arrays, you can indirectky get the size oif the second dimension too:
    public static void multiply( int[][] x, int[][] z) 
    int array2[][] = new int [x.length][x[0].length];                  
    }Of course this shoud be robustified to protect against x or x[0] being null (but in this case the multiplication is probably doomed anyway).
    Regards,
    J
    Edited by: jduprez on Mar 14, 2011 10:45 PM
    And please, in the future, use tags around code text, when posting code                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Help! Inserting a 1-D comment array into a 2-D string array at specified row AND column

    Hello everyone,
    I am writing a 2-D string array to excel and i need a way to add comments to my file like this:  
    SLAM    NAME    G Level    Comments
    1              RALF         26               
    1              RALF         26
    1              RALF         26
    1              RALF         26
    For some reason, i cannot specify a row AND column to write because: 
    When i use replace array subset it only replaces 1 element at my index. 
    When i use replace array subset with a loop, it creates empty spaces until it reaches the end of the array it is replacing.
    When i use Insert into array: i cannot wire 2 inputs for row and column.  
    In my complete VI i will need to write from row 1-1001, a different comment from 2-2002, a different comment from 3-3003, etc until a stop condition is met so i need to figure out how to do this programatically and not have it replace any elements outside of the range or it will override previous commetns. 
    I am at a loss of what to do. Any and all suggestions are greatly appreciated. 
    Thanks!
    Solved!
    Go to Solution.
    Attachments:
    array.vi ‏13 KB

    Hi proph,
    I made a small subtile change to yur VI and now it replaces all values of the 4th column…
    THINK DATAFLOW!
    Use shift registers when you need to propagate values from one loop iteration to the next!
    USE/LEARN DEBUGGING TECHNIQUES!
    There are tools like probes and highlight to understand your VI execution and to find problems…
    Go through all those free online courses offered by NI!
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    array.vit ‏12 KB

Maybe you are looking for

  • TRAN : F110 Automatic Payment

    How to change printout/data medium in F110 transaction. is it based on payment methods ?. if so how to assign this for different payment methods. how to add a customised program to existing print/data medium programs in the transaction.

  • %C4K_HWPORTMAN-4-BLOCKEDTXQUEUE: Blocked transmit queue HwTxQId0 on Switch

    Hi, On many 4506-E switch with cat4500e-entservicesk9-mz.122-53.SG1.bin, I have frequently this error : Feb 17 10:30:40.879 GMT+1: %C4K_HWPORTMAN-4-BLOCKEDTXQUEUE: Blocked transmit queue HwTxQId7 on Switch Phyport Gi2/48, count=102879 And it's always

  • How to create a file ipod nano

    I want to create a file in ipod nano  touch 6ª generations, can you helP? txt files can he read? tks

  • Converting Colors

    I am a beginner in the artwork world. I have taken a photo, converted it to grayscale, then did a live trace. I then expanded the output and deleted alot of background elements and 1.5 hours later, I saved my file.  My intention is to create a 1 colo

  • RTL language support

    Regarding Right-To-Left language support: While building a report, I would like to set the breaks list box to "First and Second Columns", but Apex assumes that column order starts from the left. In the case of Hebrew, Arabic, etc, column order begins