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

Similar Messages

  • Running average of a 2d array

    Hi,
    I am trying to get a running average but my data is a 2D array. How do you get arunning average of a 2D array. Any suggestions?
    cheers
    lp19

    Convert it to a 1D Array, and then use the existing running average tools. You can convert a 2D array to a 1D array using the "Reshape Array" function. You will need to provide this function a "length" argument, which is calculated a the product of the row-length and column-length of your 2D array. The way that I calculate this is to use the "Muliply Array Elements" function on the "size(s)" output of the "Array Size" function (see the attached image file).
    Good luck,
    -Jim
    Attachments:
    2Dto1D.JPG ‏5 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

  • Running 5 commands using array elements and waiting between?

    Hi All,
    Trying to learn PS so please be patient with me ;)
    System: PSv3 on Win2012 server running WSUS role
    I am wanting to execute 5 commands using a 'foreach' loop but wait until one finishes before moving onto the next. Can you please check out what I have and provide some suggestions of improvement? or scrap it completely if it's rubbish :(
    Current code:
    #### SCRIPT START ####
    #Create and define array and elements
    $Array1 = @(" -CleanupObsoleteComputers"," -DeclineSupersededUpdates -DeclineExpiredUpdates"," -CleanupObsoleteUpdates"," -CleanupUnneededContentFiles"," -CompressUpdates")
    #Run the cleanup command against each element
    foreach ($element in $Array1) {
    Get-WsusServer | Invoke-WsusServerCleanup $element -Whatif
    #### SCRIPT END ####
    I am assuming that I need to use @ to explicitly define elements since my second element contains two commands with a space between?
    The cleanup command doesn't accept '-Wait' so I'm not sure how to implement a pause without just telling it to pause for x time; not really a viable solution for this as the command can sometime take quite a while. They are pretty quick now that I do
    this all the time but just want it to be future proof and fool proof so it doesn't get timeouts as reported by others.
    I have found lots of code on the net for doing this remotely and calling the .NET assemblies which is much more convoluted. I however want to run this on the server directly as a scheduled task and I want each statement to run successively so it
    doesn't max out CPU and memory, as can be the case when a single string running all of the cleanup options is passed.
    Cheers.

    Thank you all for your very helpful suggestions, I have now developed two ways of doing this. My original updated (thanks for pointing me in the right direction Fred) and Boe's tweaked for my application (blew my mind when I first read that API code
    Boe). I like the smaller log file mine creates which doesn't really matter because I am only keeping the last run data before trashing it anyway. I have also removed the verbose as I will be running it on a schedule when nobody will be accessing it anyway,
    but handy to know the verbose commands ;)
    Next question: How do I time these to see which way is more efficient?
    My Code:
    $Array1 = @("-CleanupObsoleteComputers","-DeclineSupersededUpdates","-DeclineExpiredUpdates","-CleanupObsoleteUpdates","-CleanupUnneededContentFiles","-CompressUpdates")
    $Wsus = Get-WsusServer
    [String]$Logfile = 'C:\Program Files\Update Services\LogFiles\ArrayWSUSCleanup.log'
    [String]$Logfileold = 'C:\Program Files\Update Services\LogFiles\ArrayWSUSCleanup.old'
    If (Test-Path $Logfileold){
    Remove-Item $Logfileold
    If (Test-Path $Logfile){
    Rename-Item $Logfile $Logfileold
    foreach ($Element in $Array1)
    Get-Date | Out-File -FilePath $LogFile -Append -width 50
    Write-Output "Performing: $($Element)" | Out-File -FilePath $LogFile -Append -width 100
    . Invoke-Expression "`$Wsus | Invoke-WsusServerCleanup $element" | Out-File -FilePath $LogFile -Append -width 100
    Logfile Output {added 1 to show what it looks like when items are actions}:
    Wednesday, 27 August 2014 2:14:01 PM
    Obsolete Computers Deleted:1
    Wednesday, 27 August 2014 2:14:03 PM
    Obsolete Updates Deleted:1
    Wednesday, 27 August 2014 2:14:05 PM
    Expired Updates Declined:1
    Wednesday, 27 August 2014 2:14:07 PM
    Obsolete Updates Deleted:1
    Wednesday, 27 August 2014 2:14:09 PM
    Diskspace Freed:1
    Wednesday, 27 August 2014 2:14:13 PM
    Updates Compressed:1
    Boe's Updated Code:
    [String]$WSUSServer = 'PutWSUSServerNameHere'
    [Int32]$Port = 8530 #Modify to the port your WSUS connects on
    [String]$Logfile = 'C:\Program Files\Update Services\LogFiles\APIWSUSCleanup.log'
    [String]$Logfileold = 'C:\Program Files\Update Services\LogFiles\APIWSUSCleanup.old'
    If (Test-Path $Logfileold){
    Remove-Item $Logfileold
    If (Test-Path $Logfile){
    Rename-Item $Logfile $Logfileold
    [Void][reflection.assembly]::LoadWithPartialName("Microsoft.UpdateServices.Administration")
    $Wsus = [Microsoft.UpdateServices.Administration.AdminProxy]::getUpdateServer($WSUSServer,$False,$Port)
    $CleanupMgr = $Wsus.GetCleanupManager()
    $CleanupScope = New-Object Microsoft.UpdateServices.Administration.CleanupScope
    $Properties = ("CleanupObsoleteComputers","DeclineSupersededUpdates","DeclineExpiredUpdates","CleanupObsoleteUpdates","CleanupUnneededContentFiles","CompressUpdates")
    For ($i=0;$i -lt $Properties.Count;$i++) {
    $CleanupScope.($Properties[$i])=$True
    0..($Properties.Count-1) | Where {
    $_ -ne $i
    } | ForEach {
    $CleanupScope.($Properties[$_]) = $False
    Get-Date | Out-File -FilePath $LogFile -Append -width 50
    Write-Output "Performing: $($Properties[$i])" | Out-File -FilePath $LogFile -Append -width 100
    $CleanupMgr.PerformCleanup($CleanupScope) | Out-File -FilePath $LogFile -Append -width 200
    Logfile Output {added 1 to show what it looks like when items are actions}:
    Wednesday, 27 August 2014 2:32:30 PM
    Performing: CleanupObsoleteComputers
    SupersededUpdatesDeclined : 0
    ExpiredUpdatesDeclined    : 0
    ObsoleteUpdatesDeleted    : 0
    UpdatesCompressed         : 0
    ObsoleteComputersDeleted  : 1
    DiskSpaceFreed            : 0
    Wednesday, 27 August 2014 2:32:32 PM
    Performing: DeclineSupersededUpdates
    SupersededUpdatesDeclined : 1
    ExpiredUpdatesDeclined    : 0
    ObsoleteUpdatesDeleted    : 0
    UpdatesCompressed         : 0
    ObsoleteComputersDeleted  : 0
    DiskSpaceFreed            : 0
    Wednesday, 27 August 2014 2:32:34 PM
    Performing: DeclineExpiredUpdates
    SupersededUpdatesDeclined : 0
    ExpiredUpdatesDeclined    : 1
    ObsoleteUpdatesDeleted    : 0
    UpdatesCompressed         : 0
    ObsoleteComputersDeleted  : 0
    DiskSpaceFreed            : 0
    Wednesday, 27 August 2014 2:32:36 PM
    Performing: CleanupObsoleteUpdates
    SupersededUpdatesDeclined : 0
    ExpiredUpdatesDeclined    : 0
    ObsoleteUpdatesDeleted    : 1
    UpdatesCompressed         : 0
    ObsoleteComputersDeleted  : 0
    DiskSpaceFreed            : 0
    Wednesday, 27 August 2014 2:32:38 PM
    Performing: CleanupUnneededContentFiles
    SupersededUpdatesDeclined : 0
    ExpiredUpdatesDeclined    : 0
    ObsoleteUpdatesDeleted    : 0
    UpdatesCompressed         : 0
    ObsoleteComputersDeleted  : 0
    DiskSpaceFreed            : 1
    Wednesday, 27 August 2014 2:32:43 PM
    Performing: CompressUpdates
    SupersededUpdatesDeclined : 0
    ExpiredUpdatesDeclined    : 0
    ObsoleteUpdatesDeleted    : 0
    UpdatesCompressed         : 1
    ObsoleteComputersDeleted  : 0
    DiskSpaceFreed            : 0

  • Average of array elements

    Hi, I have a VI that's acquire data from Compact Field Point. These data come from cFP like an array. But I need acquire these data three times and, so, average them. There's a way to do this or I will have to use the "Index Array" function to separate each element of array and, so, make the average of each one?
    Any help will be appreciated

    It is not entirely clear to me what the array from the cFP contains (I have not used cFP). I see several possible scenarios:
    1) The array is a 1D array consisting of a single reading taken from multiple channels
    - In this case I am assuming that you want to average three of these data points. If this is the case then all you need to do is add the arrays together and divide by three.
    2) The arrayis a 1D array consisting of multiple readings from the same channel
    In this case I am assuming that you want to average all of the data from each of these sets then you can use a build array function to put make the three arrays into a single array, use the Sum function to add all of the array elements together, and then divide by the length of the array.
    3) The array is a 2D array
    In this case then you're receiving multiple readings from multiple channels. Since this solution is more difficult and I need more information to accurately answer your question I'll defer this solution unless needed.

  • Reset Array element when i run the program once

    Hi every body , i have seem many topic about reset the array element.but i can't do that well
     I want to reset all the element inside the array to the " gray color " ( the condition when i reopen the VI )
    once i run the program by clicking the buttom.
    Is there any method ?
    I have attached the pic for your reference
    Thank You
    Attachments:
    array.jpg ‏13 KB

    Post your VI with whatever method you did that you say doesn't work for you.  You must have done something wrong and we won't know what until we see the code.  Here is what it should look like.
    Message Edited by Ravens Fan on 03-02-2009 11:00 PM
    Attachments:
    Example_VI_BD.png ‏2 KB

  • How do I create an n-point running average VI?

    I've been programming in sequential written languages like C for many years now. I've been using LabVIEW for the last 4 months and am having problems writing an n-point running average VI. It is really bothering me, because this would be really trivial in C or anything else. But for some reason I can't conceive how I would do this in LabVIEW. I used LabVIEW 5 for the bulk of that time, and we just upgraded to LabVIEW 8 last week so I've been learning it. Wow, some pretty big differences between the two but the gist is the same.
    I have a 5-point running average subVI written that uses a run-once while loop with shift-registers that keep their value between subsequent VI calls. This works for what I need, but have 2 problems I would like to overcome.
    1. I can't have multiple instances of the same subVI in my top-level VI program because the way the shift-registers are keeping their value between subsequent VI calls. I have to make duplicates of the .vi file (i.e., 5_point_running_average.vi, 5_point_running_average_2.vi) in order to keep all the shift registers seperate.
    2. I want it to be an n-point running average. Currently I have to jump into the VI and add another shift register to add another point. I often change my sample rate, and thus being able to have a different averaging window is really handy.
    So the VI takes 2 inputs:
    n - (integer) the number of points to computer the average over.
    in - (real) the current data point.
    output:
    out[i] = (in[i] + in[i-1] + ... + in[i-n-1])/n
    I've also thought about the possibility of needing a 3rd input that is "instance" which might help keep variables within the subVI separated and thus not needing separate duplicate files.
    In case you are wondering, I'm using a running average to make digital HUDs easy to read. The actual data that I'm recording to file will not be going through the running average function, because as you can see by the output function, there will be a phase shift in the output. At high sample rates, the digital displays can be moving very rapidly and that makes them hard to read.
    Other recommendations as to how to make digital displays easy to read to help operators while performing tests? As for instantaneous data smoothing, so to speak. I already make the displays very large if they are critical.
    I'm very interested in this n-point running average solution. I've been scratching my head over it for awhile now and am quite stumped on how to approach this in LabVIEW.
    Help is very much appreciates,
    -nickerbocker

    The atomic operations (delete/insert) MUST do the following:
    When you insert into array, all higher elements need to be moved up one slot, then the element is inserted.
    When you delete from array, the lement needs to be deleted and all higher elements moved down one slot
    Both operations involve an array resizing operation and data shuffling in memory.
    How can LabVIEW be sure that the memory can be re-used? What if your code would delete one, but insert two at each iteration? It might well be that the LabVIEW compiler properly re-uses the memory in your particular case, but there are no guarantees. A five element array is peanuts. so it would probably be difficult to notice a difference.
    You might want to run a benchmark of the different algoritms using a huge buffer.
    "First call?" is defined as followes in the online help:
    First Call? returns TRUE the first time the VI runs after the first top-level caller starts running, such as when the Run button is clicked or the Run VI method executes. If a second top-level caller calls the VI while the first top-level caller is still running, First Call? does not return TRUE a second time.
    It will only be true exactly once during the entire execution of the toplevel VI, only the first time it is called from anywhere.
    LabVIEW Champion . Do more with less code and in less time .

  • How do I programmat​ically modify array element sizes?

    Hi All,
    I have a quick question about modifying the size of array elements. Hopefully someone can help, because I am at a dead end!
    I am logging some intensities from a Fibre Array using a camera. For calibration of the system, I acquire an image from the camera, click points on the image to divide it into areas of interest. I overlay my image with a grid showing the regions of interst - for example a 4x6 array. I then have to select the fibres - or ROIs - I want to log from.
    I have a cluster type-def ( a number and a boolean) to specify the fibre number and to turn logging from that fibre on/off. I overlay an (transparent) array of this typedef over my image to correspond with the regions of interest. So here's my problem - I want to modify the dimensions of the array so each control matches my ROI. I can resize the elements by rightclicking on the elements on the frontpanel, but can't find a way to do it programmatically. The Array Property Node>>Array Element>>Bounds won't 'change to write'...thats the first thing I tried.
    Its really only important that the elements align with my ROIs - so programmatically adding in gaps/spacings would also work for me...but again I can't figure out how to do this! I've attached a screenshot of part of my image with array overlaid to show you all exactly what my problem is.
    Thanks in advance for you help,
    Dave
    PS I am running Labview 8.6 without the vision add on.
    Solved!
    Go to Solution.
    Attachments:
    Array_Overlay.png ‏419 KB

    Here's my cheat (and cheap?) way If you want to get fancy and center the numeric and boolean indicators, you could add spacers on the north and west sides, too.
    Attachments:
    ClusterSpacer.vi ‏13 KB

  • A basic question/problem with array element as undefined

    Hello everybody,
    thank you for looking at my problem. I'm very new to scripting and javaScript and I've encountered a strange problem. I'm always trying to solve all my problem myself, with documentation (it help to learn) or in the last instance with help of google. But in this case I am stuck. I'm sure its something very simple and elementary.
    Here I have a code which simply loads a text file (txt), loads the content of the file in to a "var content". This text file contents a font family name, each name on a separate line, like:
    Albertus
    Antenna
    Antique
    Arial
    Arimo
    Avant
    Barber1
    Barber2
    Barber3
    Barber4
    Birch
    Blackoak ...etc
    Now, I loop trough the content variable, extract each letter and add it to the "fontList[i]" array. If the character is a line break the fontList[i] array adds another element (i = i + 1); That's how I separate every single name into its own array element;
    The problem which I am having is, when I loop trough the fontList array and $.writeln(fontList[i]) the result in the console is:
    undefinedAlbertus
    undefinedAntenna
    undefinedAntique
    undefinedArial ...etc.
    I seriously don't get it, where the undefined is coming from? As far as I have tested each digit being added into the array element, I can't see anything out of ordinary.
    Here is my code:
    #target illustrator
    var doc = app.documents.add();
    //open file
    var myFile = new File ("c:/ScriptFiles/installedFonts-Families.txt");
    var openFile = myFile.open("r");
    //check if open
    if(openFile == true){
        $.writeln("The file has loaded")}
    else {$.writeln("The file did not load, check the name or the path");}
    //load the file content into a variable
    var content = myFile.read();
    myFile.close();
    var ch;
    var x = 0;
    var fontList = [];
    for (var i = 0; i < content.length; i++) {
        ch = content.charAt (i);
            if((ch) !== (String.fromCharCode(10))) {
                fontList[x] += ch;
            else {
                x ++;
    for ( i = 0; i < fontList.length; i++) {
       $.writeln(fontList[i]);
    doc.close (SaveOptions.DONOTSAVECHANGES);
    Thank you for any help or explanation. If you have any advice on how to improve my practices or any hint, please feel free to say. Thank you

    CarlosCantos wrote an amazing script a while back (2013) that may help you in your endeavor. Below is his code, I had nothing to do with this other then give him praise and I hope it doesn't offend him since it was pasted on the forums here.
    This has helped me do something similar to what your doing.
    Thanks again CarlosCanto
    // script.name = fontList.jsx;
    // script.description = creates a document and makes a list of all fonts seen by Illustrator;
    // script.requirements = none; // runs on CS4 and newer;
    // script.parent = CarlosCanto // 02/17/2013;
    // script.elegant = false;
    #target illustrator
    var edgeSpacing = 10;
    var columnSpacing = 195;
    var docPreset = new DocumentPreset;
    docPreset.width = 800;
    docPreset.height = 600;
    var idoc = documents.addDocument(DocumentColorSpace.CMYK, docPreset);
    var x = edgeSpacing;
    var yyy = (idoc.height - edgeSpacing);
    var fontCount = textFonts.length;
    var col = 1;
    var ABcount = 1;
    for(var i=0; i<fontCount; i++) {
        sFontName = textFonts[i].name;
        var itext = idoc.textFrames.add();
        itext.textRange.characterAttributes.size = 12;
        itext.contents = sFontName;
        //$.writeln(yyy);
        itext.top = yyy;
        itext.left = x;
        itext.textRange.characterAttributes.textFont = textFonts.getByName(textFonts[i].name);
        // check wether the text frame will go off the bottom edge of the document
        if( (yyy-=(itext.height)) <= 20 ) {
            yyy = (idoc.height - edgeSpacing);
            x += columnSpacing;
            col++;
            if (col>4) {
                var ab = idoc.artboards[ABcount-1].artboardRect;
                var abtop = ab[1];
                var ableft = ab[0];
                var abright = ab[2];
                var abbottom = ab[3];
                var ntop = abtop;
                var nleft = abright+edgeSpacing;
                var nbottom = abbottom;
                var nright = abright-ableft+nleft;
                var abRect = [nleft, ntop, nright, nbottom];
                var newAb = idoc.artboards.add(abRect);
                x = nleft+edgeSpacing;
                ABcount++;
                col=1;
        //else yyy-=(itext.height);

  • Best way to iniitialize a queue with array elements

    Hi Guys
    I'm looking for a bit of performance optimization..  
    I'm developing a noise measurement application using LV8.6 and Win Xp /Win 7.
    To put it very simple I have a loop that samples, and a loop that does the math. data is shipped in a queue, producer / consumer style.
    So far so good.. Question is - is there a specific and more optimized way to declare this queue?
    I was wondering if declaring the queue with an initialized array element of a fixed size (the number of samples pr. read from the sound card will be known at runtime) would produce a queue that would be less heavy on dynamic allocation of memory compared to a queue obtained using a simple control no values.
    I've attached a screen dump to maybe make the question more obvious..
    I've been thru the "clear as mud" thread, as recommended in other threads that covers this topic - but i gets very high tech, and I kind of lost my way in it.. So looking for a more simple "you should use solution #x, because..."
    Thank you in advance. 
    Solved!
    Go to Solution.

    I believe (but am not sure) RT FIFOs will allocate this memory for you ahead of time. But, remember they are not deterministic on windows. You need to wire an array constant of the correct size into the FIFO read function also to avoid memory allocation, which is easy to overlook. It's worth looking into, if nothing else, assuming you have RT functions available. WIth this method, the queue size needs to be set, and you run the risk of overflowing and losing elements if not handled correctly. 
    Just throwing other options out there.
    CLA, LabVIEW Versions 2010-2013

  • Sum array elements not working

    I am trying to output the average % standard deviation per point for a series of data sets.  To do this I want to use the sum array elements function.  The program I have written should work I am pretty sure, but when I watch data flow through it, 1000 points get input into the sum function and NaN comes out.  What could cause an error like this?  I have tried inverting my array, etc.  Is there a limit to the number of points the function can take?  Or to the precision of the points being input?  Thanks, this is driving me crazy! 
    [I renamed the file and attached it again so you can open it - Molly K]
    Message Edited by Support on 07-06-2005 08:23 AM
    Attachments:
    Average % Std Dev.vi ‏23 KB
    Average.vi ‏23 KB

    Any arithmetic operation on a NaN value is invalid and must result in NaN as
    well. You probably need to make sure first that your array doesn't
    contain NaN, Inf, and -Inf.
    Rolf Kalbermatter
    Message Edited by rolfk on 07-05-2005 11:37 AM
    Rolf Kalbermatter
    CIT Engineering Netherlands
    a division of Test & Measurement Solutions

  • Problem shifting (copying) array elements in a list

    I am trying to add points to the beginning of a list. However, I cannot seem to debug the insertBeginning( ) method. I am faced with a problem that overwrites certain array elements. If I can get any help I would greatly appreciate it.
    Thanks,
    I have included a sample run and some code.
    The following url contains both the main and the class files.
    http://lbbmx.com/java/
    public void appendZ ( Point newPoint ) // used w/ insertBeg method
         size++;
         cursor=0;
         ptlist[cursor]= newPoint;
    public void insertBeginning ( Point newPoint )      // Insert begin.
              if(this.isEmpty())
                {append(newPoint);}
             else
              cursor=0;
              for(int i=size; i>cursor; i--)
                  ptlist[size]= ptlist[size-1];   //pt[1]=pt[0]
              this.appendZ(newPoint);Here is a sample run:
    Commands:
      + x y  : Append point (x,y) to the end of the list
       # x y  : Insert point (x,y) at beginning
       Q      : Quit the test program
    Empty list
    Command: +1 1
    Append (1,1)
    size = 1   cursor = 0
    0     1     2     3     4     5     6     7     
    (1,1)     
    Command: #2 2
    Insert (2,2) at beginning
    size = 2   cursor = 0
    0     1     2     3     4     5     6     7     
    (2,2)     (1,1)     
    Command: #3 3
    Insert (3,3) at beginning
    size = 3   cursor = 0
    0     1     2     3     4     5     6     7     
    (3,3)     (1,1)     (1,1)     

    ptlist[size]= ptlist[size-1];In this situation, size is the variable you are keeping track of how many elements are in your array. This does not change until after you have inserted the new Point. So, regardless of how many times you go around the loop you are simply copy the same value.
    "How do I fix it?" I hear you ask.
    Well what changes everytime you go around the loop?

  • 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.

  • 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

Maybe you are looking for

  • How can I connect my Apple TV and Airport Express to the rest of the network for the least lag?

    Hey guys, I have an Airport network here in the office.  All new Airport Extremes.  The internet comes into one, which then connects to our switches, which then connects to other Airport Extremes over ethernet.  Everything is setup to create its own

  • Charting on a specific hierarchy Level

    Hi Experts, I have created a Profit & Loss report based on an SAP Query. I've added a hierarchy group and a key figure summary. The hierarchy has 8 levels represented in a single group. I'd like bar chart level 2 of this hierarchy in the report heade

  • All my posts have been deleted!

    I have been active on the discussions forum since a few years. Now, for some reason, all my previous posts have been deleted (except for the ones that I placed today). I wonder why.

  • [SOLVED] no 5.1 sound in Xfce4

    Hello all, did a fresh install of arch last weekend, installed cinnamon and gnome 3.10.  I had sound working fine.  Since cinnamon would lock up on me (tried the update, didn't work), and didn't care of the new gnome classic, I uninstalled gnome and

  • Opening downloads.

    i'm having trouble opening pretty much anything i've downloaded. My computer is set to open everything in quicktime real player but everytime i download something to my desktop and then click to open it, it says that the 'movie' could not be opened.