Average of 2d array

i have attached a image of 2d array. i have to make average of this aaray's saperate parameter in every 1minuts
Prashant Soni
LabVIEW Engineer
Attachments:
average.PNG ‏6 KB

(Not quite a duplicate, because now we have a generic 2D array.)
The number of elements in a multidimensional array is the product of all dimensions.
So, to get the average of a multidimensional array, you take the array sum and divide by the number of elements as follows:
(same for 2D, 3D, 4D, etc.)
LabVIEW Champion . Do more with less code and in less time .
Attachments:
Average2D.PNG ‏4 KB

Similar Messages

  • How do you get the average of an array bigdecimels

    how do you get the average of an array bigdecimels... I am looping through the array in a for loop
    for (int i = 0; i < prItems.length; i++) {                                                                                                                                                                                                                                                                                                                  

    int sum = 0;
    for (int i = 0; i < prItems.length; i++) {
    sum = sum + prItems;
    int avg = sum/prItems.length;

  • 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

  • How to average each element in an array

    I have data from a Gage Card that I would like to average.  I am tuning a laser over a 50 mA range and for each 1mA increment in current, I am taking 100 scans.  Each scan consisting of about 200 points.  I cannot average more than 10 shots using the Gagecard so I would like to capture 100 scans, and average them to reduce noise.  Currently, I have my capture vi inside of a for loop which repeats 100 times and each scan writes to a file, but I would like ony 1 scan (the lower noise averaged one) per current increment.  
    How can I average each element of 100 arrays and output this to an array?
    Thanks for the help 

    It sounds like you want to average element 0 across 100 arrays and make that element 0 of the new averaged array.  Then average element 1 across 100 arrays and make that element 1 of the new array ...   ?????
    How are you working with your 100 1-D arrays now? 
    What you should do is make a 2-D array where one dimension is 100 (for the number of individual arrays) and the other dimension is how many elements are in those 100 1-D arrays.  Then you can use for loops with auto indexing to break the 2-D array down into each row or column, do the average of that array, and autoindex on the other side to build back up into the new 1-D array of averages.  You may need to to a transpose array going into your for loop in case the arrays are indexed in the wrong direction.
    Message Edited by Ravens Fan on 01-21-2008 04:26 PM
    Attachments:
    Example_BD.png ‏6 KB

  • Averaging 3D array into 1D array.

    Hi,
    I have a 3D array containing XY points of several loops and
    i am trying to average the data points of my array into a 1D array that should
    contain 1Loop with XY points. Can someone help me out?
    Thanks 
    Mutah
    Qui ose vaincra.
    Solved!
    Go to Solution.

    Hi Mutah,
    it really doesn't help so much...
    There is no 3D array in your VI, just two 2D arrays. You also don't mention what to average in those arrays: rows, columns, or something completely different?
    Also: what do you mean by "loop" ("see a loop", "final loop")? Do you mean FOR loops, WHILE loops? Or rows/columns of an array?
    At least a small hint in the attachment...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome
    Attachments:
    program.vi ‏136 KB

  • Running Average 2D(or more) Array Graphed

    I am really confused on how to plot the running average for my data. I allow the user to say how many data points they want averaged. The user can also collect up to 32 channels of data @ 1000hz.
    I understand averaging a 1D array, but how do I simultaneously plot averages when its a 2D,3D,etc array? By that I mean plot the average value for channel 0 at the same time as channel 1 at the same time as channel 2...
    Any help is appreciated, thanks!
    Lauren

    Lauren,
    It sounds like you would like to extract each channel from the 2D data array so that you can average them simultaniuosly. The best way to do this is by wiring the 2D array to the input of index array function. The funtion will morph to have an input for index(row) and index(col). You can extract one channel of the 2D array by wiring a constant to the column input. The output of this function is then a 1D array that you are used to averaging. Becasue using 32 of these may become cumbersome the function could be placed inside of a loop and the loop iteration could control the row to extract each iteration of the loop. I hope this resource helps!
    Regards,
    Shea C
    Applications Engineering
    NI

  • Averaging rows in an array

    I am trying to find the average of an array, but I need the average of the rows of each.  I don't know what function to use, because the only ones I can find take the average of the whole array.  I can't split up the array because there are a variable number of inputs that changes each time the array runs through a for loop where the user specifies the numer of times that the loop is run.

    There is a much faster possibility by using matrix multiplication. The function is called "A x B". See also attached image. The speed was faster by a factor of 13.
    Attachments:
    test.jpg ‏94 KB
    benchmark.vi ‏18 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.

  • Running Average of a 2D array element-wi​se

    Hello all,
    I am having trouble approaching this problem. I have a sub-VI which outputs a 2D-array for each iteration of a while-loop. This is spectroscopic data set where the first column is the time value and the next 32 columns are intensities from the array detector. RIght now I am fine with just figuring out how to solve my problem with only two columns. 
    Anyways, I want to be able to save the array between iterations ( which I am implementing a shift register for) and then average the next array with the previous saved array. Since all my time points will be equivalent in between iterations (the sub-VI creates a special time axis), I want to do a straight running average where each element is averaged with the previous corresponding element in the array. 
    What would be the best way to approach this part? Should I just do a build array and at the end somehow iteratively average together all of the appended arrays? I figure that would take way too long compared to a running average though. 
    Thank you for your help. I can clarify further if anything seems unclear. 

    Try using index array for elemenet by element averaging for both the arrays. You dont need buid array anyways.
    One more question, if some points are same then do averaging of those elements which are not equal or expected to be different.
    Do you have any sample data. It will be great if i have some data on which operation needs to be performed.
    Kudos are always welcome if you got solution to some extent.
    I need my difficulties because they are necessary to enjoy my success.
    --Ranjeet

  • BC4J: Any way for fast storing a large array of data

    Hi!
    I know 3 ways for storing data by using BC4J (EJB):
    1.ScrollableRowsetAccess rsAccessC =....
    rsAccessC.setColumnValue(....
    2.oracle.jbo.Transaction currentTRS = ...
    currentTRS.executeCommand("insert ....
    3.By invoking embedded function in ViewObject that use methods from oracle.jbo.server.ViewObjectImpl class.
    The last clause is more quickly than previous ones but not enough fast.
    Maybe somebody know about most efficient ways?
    Because I need store large arrays to Oracle database.
    The average size such array is 130 field multiplying by 15000 records.
    Thanks in advance
    Gali
    null

    Assume you have a big text file to work that you need
    to store and work with, what would be the best way to
    do that?Parse it into a database. Then use SQL to manipulate.

  • Display moving average in XY Chart

    Hello Everyone,
    Im trying to produce an XY Chart for Time vs Pressure.
    What I would like to do is also plot a moving average on the Chart. Can anyone suggest an example on how to do this?
    Thanks

    Hello David,
    at the moment I only find a XY Graph in my control palette, but no big difference:
    You can display more than one plot by building a cluster of plots (see the help window for the XY Graph). So you have to build two plots (pressure over time and average over time) and join them with a Build Cluster. Wire that to the XY-terminal. That's it.
    For calculating the moving average: build an array of your measurement values and get the last x elements. Calc the average of those elements. If your measurement runs in a loop, you can use shift registers instead of building an array (depends on how many elements you want to include in your average).
    Best regards,
    GerdW
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Running average of images

    Anyone know how to do a running average of images? I could convert images to 2-D arrays and stack in a 3-D array. I can't think of a way to add the images once in the 3-D array without a loop that would slow execution speed to a crawl.

    This example demonstrates how to use a running average to remove transients from captured images.
    1. Set up an acquisition and create a storage buffer, a working buffer for the current image, and a repository for the running average. The running average is a 16-bit buffer to allow for up to 256 8-bit images to be averaged together.
    2. Create an array of buffers to hold each of the images being averaged. This array works as a shift register to subtact the oldest image (step 4) and add the newest image (step 6)
    3. The calculation determines which index of the array to access. This index is then indexed for use in this iteration of the loop.
    4. For each iteration, first subtract the oldest image from the repository. You cannot subtract images that have not been stored, so subtracting occurs on the second iteration of the loop.
    5. The newly acquired image is converted to a 16-bit image and stored in the current index of the array.
    6. Add the current index to the repository and display the image. 16-bit images are dynamically ranged when displayed so that the image displayed is the average of all images added to the repository. Steps 4, 5, and 6 repeat, subtracting the oldest image and adding the newest image to create a running average.
    7. 16-bit images are signed. This step subtracts 2^15 from the repository the first time through the loop and allows access to the entire 16-bits of resolution.
    8. This step scales the histograms so that the histogram for 16-bit (average) and 8-bit (current) images cover the same range.
    9. Dispose of the buffers and WindDraw windows.
    10. This loop calculates the frames per second being handled. Notice the use of notifiers to end this while loop when the main loop ends.
    NOTE: You must have IMAQ Vision installed to run this example. The maximum number of buffers used should be no greater than 255 for 8 bit images.
    Attachments:
    IMAQ_Running_Averaging.vi ‏161 KB

  • Running average

    Hi,
    regarding running average I'd like to ask for advice. I have an application where I read analog voltages from a DSO6104a oscilloscope. 1000 samples are taken in a 20 ms Iong window in every two seconds. I want to create a running average in a way that the 1000 data points are taken, averaged and the averaged value is displayed in a chart. I tried to do the following:
    1, read the 1000 data points with the appropriate VI for that oscilloscope
    2. I get the voltage value components and store them into the array
    3. I summarise the content of the array
    4. divide it by 1000.
    This is how I thought it should be but the results are some weird numbers. Can you please advise where it's gone wrong/how to make it better.
    Thanks,
    Krivan
    Attachments:
    runavg.PNG ‏5 KB

    krivan wrote:
    Thanks both of you for the advices! 
    Ermm...I thought that a running average is basically an instantaneous average...what is the real difference?
    There is a difference: http://en.wikipedia.org/wiki/Moving_average.
    What I try to achieve and confused about is that there is an input data stream which is read by the ag6000a single channel VI. It reads 1000 samples in every 2 seconds [wait time in the while loop]. The output of the read VI connects to a waveform chart displaying the actual voltage values but at the same time I would like to average these 1000 data points and put the averaged value into another waveform chart. I think how I've done it - the getComponents+array - is not correct...
    How is it possible to average these 1000 data points and display them in every loop sequence?
    You don't show the rest of the code, but (as has been pointed several times) the Mean VI will give you the average of the array you get from the read . You can wire this value directly to a chart. You mentioned charts, so I assume you know the difference between a chart and a graph? If not, please review the help on graphs and charts and look at the examples that ship with LabVIEW.

  • Spatial Average

    Hi all.
    I'm very new to all this spatial business so bare with me.
    I need to calculate the average value of an attribute within a region.
    I have two tables. One that contains a cell_id, and the geometry column is a polygon that defines the bounding box of the cell. Each cell is approx 25km by 25km.
    In another table i have a reading for each cell for each day over a period of a few months.
    I need to be able to calculate the average over regions. For example the average for regions with a spatial resolution of 10 degrees.
    Does anyone know how i can do this?
    I realise i could build a query window and do a seperate query for each region. But that would be very very slow. Any other ideas?
    Thanks bec.

    I don't think that there is an out-of-the-box solution for your task but if I understandd you correctly the only thing you will have to do is to average the power associated with each 1/n octave band of all your microphones. In the S&V toolkit the band power is an output parameter of e. g. the SVT Third-octave Analysis.vi. The band powers for each channel are stored within arrays so you will simply have to average the corresponding array elements from each of your channels.
    Best regards,
    Jochen Klier
    National Instruments Germany

  • LabVIEW Signal Express, averages

    Hello,
    I'm brand new to LabVIEW. I have a temperature signal  from a thermocouple up in LabVIEW express, and I'm trying to get an average of this signal because it's very noisy. Can anyone provide me with very detailed help (as I'm brand new, and have no idea how to do anything in LabVIEW).
    If it's of any help, I have LabVIEW 8.5 and LabVIEW Signal Express 2.5.1. Thank you!

    Hello ddrop,
    To add to Intelligent's post, here is another example to show you how to create a running average of an array.  I am not sure how you have your measurements recorded (if you are creating an array), but this example should give you some added guidance.
    You mentioned you were using Signal Express and there are a set of Signal Express examples that may also be helpful.  You can find the examples by going to Help>>Open Example...  This should take you here: C:\Program Files\National Instruments\SignalExpress\Examples.  From there, you can go to Loops>>Frequency Sweep with Averaged Measurement.seproj. While this example does not do exactly what you are doing, it will at least give you an idea of how to do averaging in Signal Express.  Another way to incorporate the averaging in Signal Express would be to do a Run LabVIEW VI step.  I hope this helps!
    Kim W.
    Applications Engineer
    National Instruments

Maybe you are looking for