Averaging the rows in a 1D array as samples are taken

I am continuous taking 10 samples of voltage every second and therefore the output (Y) every second is  an array of one column and 10 rows.  How do I create loop that will average the rows of each sample taken.  For example, after 8  seconds I will have 8 arrays--from these array I want to average the 8 values in the 1st row of each array. Ultimately I want to ouput a 10 row array where each row is a mean value.
I'm new at programming and Labview so thanks in advance!

For your code, you have a 1D array, so why would you built it into a 2D array. Makes no sense.
Here's a quick draft on how to average your Y array. Use the while loop for the shift register.
You also don't need the big sequence structure. Dataflow fully determines execution order.
Message Edited by altenbach on 07-10-2009 01:07 PM
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Averaging.PNG ‏12 KB

Similar Messages

  • How to add the rows formatted as table headings, Tables headings are repeated when a table spans more than one page.

    Hi all,
    i am facing problem while generating Test Result word document after successful execution of TestStand.
    The Problem is :
    i want to add rows Formatted as table headings, table headings are repeated when a table spans more than one page(marked as Red).
    Example:
    Page  No. 1
    |     Test case Number  |  Test Step number      |
    |      100                         |            100                   |
    Page  No. 2
    |     Test case Number  |  Test Step number      |
    |      200                         |            300                   |
    Test Result word document should generate with Table headings(marked as Red) in every pages of the document, but i am not getting as per above example.
    Please through light on this.
    Regards,
    Susa.

    Hi Santiago,
    Thank you very much for your valuable reply.
    i want to generate MS-word report for TestStand after successful testing using MS-word2000.
    Test report contains Actual values, Expected values and Pass/Fail status.
    In my program i have customized all  fields i can able to generate test report which contains Verification engineer name , test mode, test date, start time, end time Actual values, Expected values and Pass/Fail status.etc....
    To put all values of test case number, Test step number, Actual values, Expected values and Pass/Fail status in to table for each time, i will
    insert a row into table every time values arrives, once the table exceedes its page size it moves to the next page, next page should start with table row header  but it start with  values of above said parameters.
    so i'm not able to repeat table row header for each page.
    Please find the attached file for your reference.
    Attched file expected.doc  :   This file contains what i wanted to generate MS-word report. Here table row header "Test Case Number and Test Step Number " is repeated in second page.
    Attached file Actual output from source code.doc   :  This report generated from the source code. Here table row header "Test Case Number and Test Step Number" is not repeated in second page.
    Do you know any property to set "repeat as header row at the top of each page" using MS-word ActiveX in CVI/Labwindows.
    i think this information is sufficient for you,
    Still if you need some information please ask me.
    Thanks
    Susa.
    Attachments:
    Actual output from source code.doc ‏25 KB
    expected.doc ‏26 KB

  • How do I graph plots from the rows of a 2D array?

    I am working on a project in which I have generated a 2D array of values, and would like to graph each row as its own plot. Does anyone have a suggestion for the simplest way to do this? (All the plots should be on the same chart)
    Solved!
    Go to Solution.

    Tim Elsey
    LabVIEW 2010, 2012
    Certified LabVIEW Architect

  • Fetching row and return as array

    I am trying to retrieve the results from a query of my Oracle 9i database. In every call it should retrieve a single row from the results and returns it as an array, where each field of the row is in an array key.
    My attempt but it doesnt give me any data:
    //get userParameter here etc.. while (rs.next()) { String inf []; rs = stmt.executeQuery("select * from Customers where ID = " + userParameter); String firstname = ""; String lastname = ""; if(inf.equals(getParameterValues(rs)) {   out.write(inf[firstname]);   out.write(inf[lastname]); }

    Evergrean wrote:
    I am trying to retrieve the results from a query of my Oracle 9i database. In every call it should retrieve a single row from the results Are you sure that the query always results in a single row?
    and returns it as an array, where each field of the row is in an array key.No, not every field. Just the primary key. Makes no sense.
    My attempt but it doesnt give me any data:
    //get userParameter here etc..
    while (rs.next())
    String inf [];
    rs = stmt.executeQuery("select * from Customers where ID = " + userParameter);
    String firstname = "";
    String lastname = "";
    if(inf.equals(getParameterValues(rs)) {
    out.write(inf[firstname]);
    out.write(inf[lastname]);
    I'd do it like this:
    (1) Start with a Customer class, with id, firstName, and lastName as data members.
    (2) Write a DAO that can access a Customer by id:
    public class CustomerDao
        private static final String CUSTOMER_SELECT_SQL = "select * from Customers where ID = ?";
        private Connection connection;
        public CustomerDao(Connection connection)
            this.connection = connection;
        public Customer find(Long id) throws SQLException
            Customer customer = null;
            PreparedStatement ps = null;
            ResultSet rs = null;
            try
                ps = this.connection.prepareStatement(CUSTOMER_SELECT_SQL);
                ps.setLong(1, id);
                rs = ps.executeQuery();
                while (rs.next())
                    // map values to Customer here.
            catch (SQLException e)
                e.printStackTrace();
            finally
                DatabaseUtils.close(rs);
                DatabaseUtils.close(ps);
            return customer;
    }The rest is left to you.
    %

  • What is the maximum rows allowed in PLSQL array table type?

    Hi,
    I have a procedure and it contains the cursor which will fetch more than 500 records. And i have 5 output parameters to store the values coming from the cursor. I don't want to store that into custom table. I want to save it one table type array or something like that. Now i want to know what is the maximum storage of array table type? If i store more than 500 data, how will be the performance? Then is there any other way to achieve this? And that should not decrease the preformace.Let me know your thoughts.
    Thanks

    It really depends on what you are planning to do with the records once you return them from your stored procedure, and what client is on the receiving end of the results.
    One option would be to just return a ref cursor and let the client deal with retreiving the rows themselves, whether one by on or by a bulk collect. Another option would be to declare a table of records matching the result set and do a bulk collect into that table type in your procedure and return the table type to the caller. You could also declare a table type for each field in the resultset, bulk collect the records into thos types and return one for each field.
    Personally, I would likely go with returning a ref cursor. Both of the collect the resultset in your procedure and then return collections to the caller methods require memory on the database server to hold the entire resultset and memeory on the client to hold the entire resultset. While 500 records is probably not going to be too bad on memory, if the result set grows, you will run into memory issues at some point.
    John

  • 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];

  • Random selection of rows from a 2D array then subset both the rows that were selected and those that were not. Please see message below.

    For example, I have a 2D array with 46 rows and 400 columns. I would like to randomly select 46 data rows from the 2D array. By doing the random selection it means that not all individual 46 rows will be selected some rows may appear more than once as there may be some duplicates or triplicates in the random selection. The importan thing is that we will have randomly selected 46 rows of data (no matter that some rows appear more than once). Then I would like to subset these randomly selected 46 data rows (some which will be duplicated, or triplicated, etc.) and then also find and subset the rows that were not selected. Does this make sense? Then i would like to do this say 10 times for this data set. So that then I will have 2 by 10 data sets: the first 10 each with 46 rows and the other 10 with n rows depending on how many WERE NOT randomly selected. i hope that my explanation is clear. I am relatively new to Labview. It is really great so I am getting better! If anyone can help me with this problems it will be great. RVR

    Start by generating randon #s between 0 and 45. Run a for loop X times and in it use the random function, multiply the result by X and round down (-infinity). You can make this into a subVI, which you can reuse later. In the same loop, or in a different one, use Index Array to extract the rows which were selected (wiring the result out of the loop with auto indexing causes it to be rebuilt into a 2D array).
    One possible solution for the second part would be to go over the array of randomly generated numbers in a for loop and use Search 1D Array to find each of the numbers (i). If you get -1, it means the row wasn't selected and you can extract it.
    I hope this puts you on the right path. If not, don't be afraid to ask more.
    To learn more about LV, I suggest you read the LabVIEW user manual. Also, try searching this site and google for LabVIEW tutorials. Here and here are a couple you can start with. You can also contact your local NI office and join one of their courses.
    In addition, I suggest you read the LabVIEW style guide.
    Try to take over the world!

  • Finding and averaging multiple rows

    Hello,
    I am having a little problem and was wondering if anyone had any ideas on how to best solve it. 
    Here is the problem: 
    - I have a large file 6000 rows by 2500 columns. 
    - First I sort the file by columns 1 and 2
    - then I find that various rows in these two columns (1 and 2) have duplicate values, sometimes only twice, but sometimes three or four, or five or up to 9 times.
    - this duplication occurs in only the first two columns, but we don't know in which rows and we don't know how much duplication there is. The remaining columns, i.e. column 3 to column 2500, for the corresponding rows contain data.
    - Programatically, I would like to find the duplicated rows by searching columns 1 and 2 and when I find them, average the respective data for these rows in columns 3 to 2500.
    - So, once this is done I want to save the averaged data to file. In each row this file should have the name of colunm 1 and 2 and the averaged row values for columns 3 to 2500. So the file will have n rows by 2500 columns, where n will depend on how many duplicated rows there are in the original file.
    I hope that this makes sense. I have outlined the problem in a simple example below:
    In the example below we have two duplicates in rows 1 and 2 and four duplicates in rows 5 to 8.
    Example input file: 
    Col1 Col2 Col3 ... Col2500
    3 4 0.2 ... 0.5
    3 4 0.4 ... 0.8
    8 5 0.1 ... 0.4
    7 9 0.7 ... 0.9
    2 8 0.1 ... 0.5 
    2 8 0.5 ... 0.8
    2 8 0.3 ... 0.2
    2 8  0.6 ... 0.7
    6 9 0.9 ... 0.1
    So, based on the above example, the first two rows need averaging (two duplicates) as do rows 5 to 8 (four duplicates). The output file should look like this:
    Col1 Col2 Col3 ... Col2500
    3 4 0.3 ... 0.65
    8 5 0.1 ... 0.4
    7 9 0.7 ... 0.9
    2 8 0.375 ... 0.55
    6 9 0.9 ... 0.1
    Solved!
    Go to Solution.

    Well, here's an initial crack at it. The premise behind this
    solution is to not even bother with the sorting. Also, trying to read
    the whole file at once just leads to memory problems. The approach
    taken is to read the file in chunks (as lines) and then for each line
    create a lookup key to see if that particular line has the same first
    and second columns as one that we've previously encountered. A shift
    register is used to keep track of the unique "keys".
    This
    is only an initial attempt and has known issues. Since a Build Array is
    used to create the resulting output array the loop will slow down over
    time, though it may slow down, speed up, and slow down as LabVIEW
    performs internal memory management to allocate more memory for the
    resultant array. On the large 6000 x 2500 array it took several minutes on my computer. I did this on LabVIEW 8.2, and I know that LabVIEW 8.6
    has better memory management, so the performance will likely be
    different. 
    Attachments:
    Averaging rows.vi ‏30 KB

  • Average values of a 2-D array

    Hi folks,
    quite simple question, just want a simple solution. I've got a 2-D x*y array, need the average value of all the y volume numbers, which means eventually I will have a x*1 1-D array. Is there any simple solution instead of 2 loops? Cheers. 

    Here is an example with a switch for row or column averaging.  The TRUE case of the case statement contains a Transpose 2D Array.
    If you want to average the whole array, you can do this easily by using Reshape Array, then Mean.vi.   Here is that example.
    Message Edited by DFGray on 10-28-2009 07:39 AM
    This account is no longer active. Contact ShadesOfGray for current posts and information.

  • How can I get all the values of a String array profile property using javascript?

    I am trying to build functionality into our site that records all products added to the basket against a user's profile.
    I have so far been able to store the product codes against the profile as a property using Ajax:
           var dataString = ":formid=addProduct&:formstart=/apps/thread/templates/page_product/jcr:content/par/produc t/formstart&:redirect=/content/thread/en/user/cart.html&productId=151515:profile="+profile ;
                         $.ajax({ 
                type: "POST", 
                url: "/content/women/evening/dresses/l-k-bennett-davinadress.html", 
                data: dataString, 
                success: function(data) { 
    In this example I have hardcoded a product ID of 151515.
    In order to save the property as a multi string field you simply replace &productId=151515 with &productId=151515&productId=131313&productId=141414 or as many extra values as you want to build into that string. This stores a productId property against a user profile.
    The issue comes from calling that data back. Using var value = CQ_Analytics.ProfileDataMgr.getProperty("productId") I can get the first value of this array (or the single value if only one is stored).
    However there does not seem to be a way to get any of the other stored values in the array using getProperty. Does anyone know how I can achieve this?

    Hi,
    Don't think that's possible. Even if it were, you wouldn't be able to use/display BOOLEAN type in SQL.
    If you just aim to see what they are, you could do something like this
    select text
      from all_source
    where owner = 'SYS'
       and name = 'DBMS_DB_VERSION'
       and type = 'PACKAGE';Or even
    select dbms_metadata.get_ddl('PACKAGE', 'DBMS_DB_VERSION', 'SYS') from dual;My version is:
    SQL> select * from v$version where rownum = 1;
    BANNER                                                         
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi
    1 row selectedIn 11g you also have [PL/SCOPE|http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10471/adfns_plscope.htm#ADFNS02203] which might help you even more.
    Regards
    Peter

  • How to clear the rows in a jTable

    Can anyone tell me how to clear the contents of all the rows in a jTable?

    This is how I did. Posting the same.
    jTable1.selectAll();
    int[] array = jTable1.getSelectedRows();
    for(int i=array.length-1;i>=0;i--)
    DefaultTableModel model = (DefaultTableModel)jTable1.getModel();
    model.removeRow(i);
    Regards.

  • Why the row and column reverses?

    I have an image 736 pixels (row) and 554 pixels (column). In the IMAQ ColorImageToArray.VI, the VI has a 2D array with Y axis as the first dimension (Dim) of the array and X-axis as the second Dim. Why do we break away from the tradition of the first dimension of a 2D-array is the row and the second dimension is column? When I go to use the Index Array function, the index 0 is row and index 1 is column, as the little hint or tip trying to give me clue.
    I am confused.
    Attachments:
    image_2.jpg ‏76 KB
    NIquestion.vi ‏30 KB

    Don't know the answer but I can give an idea that just might make make sense.
    It has to do with keeping the various indexes of multi-dimensional arrays straigt in my head.
    Think of a 7-d array as a library. To find a letter on a page of a book you would first go the correct Floor.
    Then the correct isle of shelves.
    Then the correct shelf.
    Then the book.
    Then the page.
    Then the line (i.e. row).
    then the character on the line (column).
    Using this model higher "d" arrays are just collections of the lower arrays.
    The smallest "d" array is comprised of only columns.
    This model is a lot easier for me to handle, than trying to visualize a 3-d array inside 4-space.
    Ben
    Ben Rayner
    I am currently active on.. MainStream Preppers
    Rayner's Ridge is under construction

  • With out selecting the Row, display Dropdown for a perticular column

    Hi,
    i have a requirement to display dropdown to perticular column in a Tableview.
    is it posible.....?
    Regards,
    Brahmaji

    Hi,
    The value of the TextEdit inside a Tableview, can be got by using the same method that you use it outside the tableview.
    If you know the id of the Textview, then you could get the data inside the textview easily.
    All the form fileds will be stored in form_fields table that is stored in the request object.
    This also implies that the textedit value will also be stored inside the form_fields array.
    The textedit value can be read from this internal table using the below syntax.
    The syntax for reading the textedit value is below...
    data: lv_string type string,
             lv_te_iid type string.
    lv_te = 'te1'.
    lv_string = request->get_form_field( NAME =  lv_te ).
    The id of the textedit should be assigned  by you, during the factory method. Say for example te_1_1 i.e. te_<row_number>_<column_no>
    Later in the event handler based on the no. of questions, you could loop and form the id of the text_edit and get the value of the text edit and store the value of the textEdit in the internal table based on the row index.
    Hope it helps.!
    Regards,
    Maheswaran
    Edited by: Maheswaran B on Nov 6, 2009 10:00 PM
    Edited by: Maheswaran B on Nov 6, 2009 10:02 PM

  • Get the number of elements in Array

    Hi everyone,
    Could anyone give me idea on how to get the number of elements in an Array (not number of rows) ?
    I tried to find that in both property node and array functions but nothing.
    Thanks,
    -Kun

    You are going to have to provide some proof that the Array Size does not work correctly. Right click on the input to it and select 'Create Indicator'. Run the VI. Go to the front panel and select 'Edit>Make Current Values Default'. Save the VI and attach it to your post.
    You can also check the array size yourself. Right click on the index display of the array and select 'Advanced>Show Last Element'. I will bet you that number shown is equal to Array Size -1.
    p.s. The number of elements in an array is equal to the number of rows in a 1D array. If you define the number of elements as anything else, you are mistaken.
    Message Edited by Dennis Knutson on 04-21-2009 10:40 AM

  • How to get rank within the row in SQL

    I have an a key orderid and 4 other columns with orderdate&time in (16/12/2011 16:15:24 format) within a table.
    the orderid has an average of 1million rows every week hence could not do this in excel for a 15 day period .
    ORderid.........: mail........................................ : telephone ............................:online ........................................ store.......................... Agency
    A3456...........15/12/2011 16:15:24 ............... 16/12/2011 14:12:01.............16/12/2011 16:14:00..........17/12/2011 11:22:55 ............12/12/2011 22:20:30
    B678
    C555
    i want to create a new table which ranks each row according to the max orderdate and time say in another table
    i want to capture the rank
    KEY.......Mail............Tel............online.........store..........Agency
    A3456.....4 ...............3...............2...............1............... 5
    Is there any way either within the same table or in other table i wiould be able to get the rank based on the rows in SQL.
    thnks
    Edited by: UOOLK on 29-Dec-2011 06:46

    Something like this I think:
    create new_order_table as
      select order_id
            ,rank() over (order by mail desc) mail
            ,rank() over (order by telephone desc) telephone
            ,rank() over (order by online desc) online
            ,rank() over (order by store desc) store
            ,rank() over (order by agency desc) agency
        from old_order_table;Assuming you want the most recent date to be ranked number 1. If you want number 1 to be the oldest then remove all the 'desc's from the order by clauses.

Maybe you are looking for

  • Error in Connection Test when connecting to R/3

    Hi All, Although I am able to connect to the R/3 server through the portal (SAP screen is visible and the transactions are running,) the Connection Test fails at the second step i.e. the Connector settings and User Mappings. I have checked these sett

  • Settlement Rule for Process order

    Hello While creating process,subject to other configuration,the settlement rule when checked in header,there is default receiver category for material. In customizing,do we create such a rule or same is by default Thx

  • Is There A Bug In 4.3.2?

    I'm just setting here wondering if 4.3.2 has a bug? When i try to sing my iPad with iTunes, The Apps in iTunes 10.2.2 are only showing 16 apps PER page, and my iPad has 20 per page. I can add 4 apps in iTunes, but when i sync it, it will pull the bot

  • Reader extensions option

    We recently purchased Livecycle ES4 and was wondering how to the set the pdf with reader extensions, there dont seem to be an option available of which It was readily available in our copy of Acrobat 9. Any help is appreciated

  • Hide bounding box of a selected object

    I tried using the feature request page but got an error after typing all this and thankfully I copied all of the text I entered just before hitting submit just in case the website decided to act stupid like it did (would have to retype all of the fol