Making an average of the last 100 values?

Hi everyone,
I am acquiring a signal every 1000mS with Labview 7.1. I need to make an average of the last 100 values every 1000mS. I know how to do this with shift registers but it would be a bit long to do it this way...There must be a better way
Would anybody have an example of an array that takes into consideration the new value that has just been acquired, so that I can make an average of the array?
Thank you very much for your help,
Toto

Hi Toto,
Here is the first thing I thought of.  Initialize an array of 1000 elements, and replace an element each iteration of the loop.  Use the Quotient and Remainder function along with the iteration count of the loop to replace the oldest element in the array.  Add the array and divide by 1000 in each iteration to get the current average.  I've attached the VI (saved in LabVIEW 7.1), along with a screenshot for anyone who wants to see it but doesn't have LabVIEW 7.1 or later.
Good luck,
-D
Message Edited by Darren on 02-05-2006 07:40 PM
Darren Nattinger, CLA
LabVIEW Artisan and Nugget Penman
Attachments:
Running_average.vi ‏11 KB
Running_average.jpg ‏32 KB

Similar Messages

  • Average of the last 1000 values

    Hello all,
       I am taking continous measurement and I wanted to average the last 10000 readings and stop the loop if the stanard deviation is less then 0.2. I couldnt configure how to delete the earlier data than the last 10000 measurements. 
    Thanks

    Look in the Signal Processing->Point by Point->Probability and Statistics PtbyPt palette.  There is a mean and a standard deviation in there.  It will do it all for you.
    There are only two ways to tell somebody thanks: Kudos and Marked Solutions
    Unofficial Forum Rules and Guidelines

  • New measurement starts with the last measurement value before program stop

    New measurement starts with the last measurement value before program stop. This is very embarrassing because we finish at a high measured value and start with small value, which can not be seen on the autoscale screen due to the memorized high first value. We use NI PCI-6220 DAQ board and software written in LabView 7.1 using Express VIs and running in the LabView environment. The program (attached) every half second measures 3 AI channels, filters and scales the data, visualizes, averages and saves it in a file. Please advise me how can I avoid this problem. Please note that I am not very experienced in LabView.
    Attachments:
    OLED_Monitor2.vi ‏785 KB

    I can not run your vi, but if you initialize your controls you should be ok.
    Look at the picture
    Attachments:
    Clipboard-2.jpg ‏16 KB

  • How to get the last "reported" value in a cross tab

    Dear all,
    based on a BeX Query Universe I have built a report with a cross tab in webI.
    Maybe you can help me with the following issue. There I have a problem: I want to get in the Total-column always the last reported value, e.g. for Number Total Customers "66", not for Mar or Apr, because they are null.
    Calendar Month                      |Jan| |Feb| |Mar| |Apr| |Total|
    Number Total Customers         |54|    |66|  | |      | |       66
    Number Active Customers      |57|    |71|  | |      | |       71
    I hope that you understand my problem and could help as soon as possible.
    Thanks a lot in advance for your support.
    Best regards.
    Edited by: HOLWUE on Feb 8, 2010 1:40 PM

    Hi,
    If this question is related to Webi then post in the below forum.
    http://scn.sap.com/community/businessobjects-web-intelligence/content?filterID=content~objecttype~objecttype[thread]
    Regards,
    Sujit.

  • Using an index to access the last n values of a certain combination

    I have a large table of the following form:
    Name Typ
    ID NUMBER
    M_DATE DATE
    M_LOC NUMBER
    M_ARTICLE VARCHAR2(30)
    M_TYPE VARCHAR2(30)
    M_MEASURE VARCHAR2(50)
    VALUE NUMBER
    In this table there is only a small number of different locations, articles, types and maesures but a large number of m_date values.
    I want to access the last 10 values for a certain combination of locations, articles, types and measures.
    I have an index
    create index i_res_2 on results (m_loc, m_article, m_type, m_measure, m_date);
    In my opinion it should be possible to access the last 10 values directly by this index, but
    when I do my select in the following way it seems to me that first all datasets with the same
    locations, articles, types and maesures are selected, then sorted by date and then the last 10
    dates are selected. As those datasets are spread over the whole table it needs a higher number
    of physical reads. Is there a way to have an index on m_date and an other form of this query
    that selects the requested values with less phyical reads? (Database version is 10.2)
    SQL> select
    2 id,
    3 m_date,
    4 value
    5 from (
    6 select
    7 id,
    8 m_date,
    9 value,
    10 rank() over (order by m_date desc) r
    11 from results
    12 where m_loc = '14001'
    13 and m_article = '11211-00-00'
    14 and m_type = '0002'
    15 and m_measure = '032')
    16 where r <= 10
    17 order by m_date asc;
    ID M_DATE Value
    3931958 05.03.10 69.00
    3931960 05.03.10 69.00
    3905712 10.03.10 68.60
    3999535 10.03.10 69.70
    3985125 11.03.10 69.40
    3957851 11.03.10 69.60
    3949799 21.03.10 68.70
    4017369 21.03.10 69.00
    3951981 22.03.10 68.80
    3983554 22.03.10 68.80
    Abgelaufen: 00:00:03.00
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 48 | 6 (34)| 00:00:01 |
    | 1 | SORT ORDER BY | | 1 | 48 | 6 (34)| 00:00:01 |
    |* 2 | VIEW | | 1 | 48 | 5 (20)| 00:00:01 |
    |* 3 | WINDOW SORT PUSHED RANK | | 1 | 39 | 5 (20)| 00:00:01 |
    | 4 | TABLE ACCESS BY INDEX ROWID| RESULTS | 1 | 39 | 4 (0)| 00:00:01 |
    |* 5 | INDEX RANGE SCAN | I_RES_2 | 1 | | 3 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    2 - filter("R"<=10)
    3 - filter(RANK() OVER ( ORDER BY INTERNAL_FUNCTION("M_DATE") DESC )<=10)
    5 - access("M_LOC"=14001 AND "M_ARTICLE"='11211-00-00' AND "M_TYPE"='0002' AND
    "M_MEASURE"='032')
    Statistiken
    1 recursive calls
    0 db block gets
    547 consistent gets
    474 physical reads
    0 redo size
    766 bytes sent via SQL*Net to client
    380 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    2 sorts (memory)
    0 sorts (disk)
    10 rows processed

    I found a solution, which is much better in terms of physical reads and consistent gets even if the optimizer calculates higher costs. But I still think, that there should be an easier way to do this:
    SQL> select
    2 id, m_date, value from results
    3 where
    4 (m_loc, m_article, m_type, m_measure, m_date)
    5 in
    6 (select m_loc, m_article, m_type, m_measure, m_date
    7 from (
    8 select /*+ first_rows(10) */ m_loc, m_article, m_type, m_measure, m_date
    9 from results
    10 where m_loc = '14001'
    11 and m_article = '11370-00-00'
    12 and m_type = '0002'
    13 and m_measure = '032'
    14 order by m_loc,m_article,m_type,m_measure,m_date desc
    15 ) where rownum < 10);
    ID M_DATE VALUE
    2495995 01.02.09 70,4
    2457657 19.01.09 66,9
    2556262 13.02.09 67,4
    2496232 01.02.09 67,6
    2465051 20.01.09 67
    2454994 19.01.09 67,4
    2545951 13.02.09 67,4
    2502216 01.02.09 67,5
    2497533 01.02.09 67,2
    9 Zeilen ausgewählt.
    Ausführungsplan
    Plan hash value: 3924867000
    | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
    | 0 | SELECT STATEMENT | | 1 | 122 | 8 (25)| 00:00:01 |
    | 1 | TABLE ACCESS BY INDEX ROWID| RESULTS | 1 | 39 | 3 (0)| 00:00:01 |
    | 2 | NESTED LOOPS | | 1 | 122 | 8 (25)| 00:00:01 |
    | 3 | VIEW | VW_NSO_1 | 1 | 83 | 4 (25)| 00:00:01 |
    | 4 | HASH UNIQUE | | 1 | 31 | | |
    |* 5 | COUNT STOPKEY | | | | | |
    | 6 | VIEW | | 1 | 31 | 4 (25)| 00:00:01 |
    |* 7 | SORT ORDER BY STOPKEY| | 1 | 31 | 4 (25)| 00:00:01 |
    |* 8 | INDEX RANGE SCAN | I_RES_2 | 1 | 31 | 3 (0)| 00:00:01 |
    |* 9 | INDEX RANGE SCAN | I_RES_2 | 1 | | 2 (0)| 00:00:01 |
    Predicate Information (identified by operation id):
    5 - filter(ROWNUM<10)
    7 - filter(ROWNUM<10)
    8 - access("M_LOC"=14001 AND "M_ARTICLE"='11370-00-00' AND "M_TYPE"='0002'
    AND "M_MEASURE"='032')
    9 - access("M_LOC"="$nso_col_1" AND "M_ARTICLE"="$nso_col_2" AND
    "M_TYPE"="$nso_col_3" AND "M_MEASURE"="$nso_col_4" AND "M_DATE"="$nso_col_5")
    Statistiken
    1 recursive calls
    0 db block gets
    36 consistent gets
    14 physical reads
    0 redo size
    748 bytes sent via SQL*Net to client
    381 bytes received via SQL*Net from client
    2 SQL*Net roundtrips to/from client
    1 sorts (memory)
    0 sorts (disk)
    9 rows processed

  • Formula to calculate the last active value in a row?

    When using a simpe table, what formula will display the last active value in the row? Some of the cells are blank. I want a column to show the most recent value, which in this case will be the rightmost, non-blank cell.

    B2 through J2 are your data
    B3 =IF(B2="","",COLUMN())
    Fill that to the rest of row 3
    A2 =INDEX(B2:J2,MATCH(MAX(B3:J3),B3:J3,1))
    If there are no values in the row, the answer will be an error triangle. You can put the IFERROR function around the formula and give it an answer when there is an error.

  • While P.O creation material automatic capture the last Purchase value

    Dear all
    Please guide me for the following :
    I need a scenario like while creation of new P.O if material already purchase then system automatic capture the last purchase value as per the given material....
    Thanks & Regards,
    Neha

    Prompt the last Purchase Order Price for the Material
    If you want the system to take the price from the last Purchase Order, then do not maintain the conditions in the info record because it has precedence over the last PO. This means that the netprice field in the info record should be left blank.
    In the case when you have already maintained the conditions in the info record (or netprice), try to delete them or make them invalid by changing the validity date.
    Even though no price was maintained, the info record will still keep track of the Order price history.
    To check the Order price history, go into the material info record and click Environment -> Order price history
    Edited by: Sachein on Oct 20, 2011 6:54 AM

  • Is it possible to maintain the last AO value after the DAQmx task is done on device DAQ USB-6341 ?

    Hi all,
    I use the device DAQ USB-6341 to generate the desired voltage waveform by the "finite samples" sample mode.
    I notice that the channel resets to zero volts after the DAQmx task is done and the DAQ USB-6341 does not have 
    the property AO.idleOutputBehavior to select "Maintain Existing Value".
    How can I maintain the last AO value after the DAQmx task is done on device DAQ USB-6341 ?
    Thanks.
    Godel

    How many computers do you have in the network?
    What is the IP address and default gateway number on your computer?
    In order to connect to the wireless network, WVC80N should get valid IP address from the access point.
    If the access point has capacity to assign a private IP address to the computers and devices then I think you can use WVC80N.

  • How to find the last string value in dynamic object?

    Hi All,
    I am trying to find the last string value in dyanamic objects,Any one have solution for this.
    Ex:
    my data :12347-ebjdone-525-ecgfjf-25236-defdafgdeg
    And i want to show the output is :defdafgdeg
    Any ideas:
    Thanks
    Srini

    For oracle try using oracle function.
    e.g.
    SELECT  reverse(substr(reverse('12347-ebjdone-525-ecgfjf-25236-defdafgdeg'),1,instr(reverse('12347-ebjdone-525-ecgfjf-25236-defdafgdeg'),'-','1'))) from dual
    Object definition might look like:
    reverse(substr(reverse({ObjectName}),1,instr(reverse({ObjectsName}),'-','1')))
    Regards,
    Kuldeep
    Edited by: Kuldeep Chitrakar on Feb 12, 2010 8:12 AM

  • Getting the last selected value of the combo  - very very urgent...........

    On my panel i have a jcombobox in upper half(which displays say the address type.) and few text fields on the lower half(which displays the add details). when the user selects a value in the combo box the text fields are populated based on the selection. The user can change the values displayed in the text fields. So before setting the new values in the text fields the last displayed values need to be saved.
    I have an ActionListener for my combo which gives me the currently selected value by calling getSelecetdItem()
    How can i get the last selcted value of the combobox without using any variable of my own.

    To update the last displayed details(the address details say) i need to check what type of address the combo had previousely.....
    when i display the panel first time the home address is set by default and i have a variable to hold this value..as the user changes the selection i update the variable...I don't want to use this variable..instead if i can get the last selcted value from the event that would be great...
    thanks

  • DAQmx :: Continous reading of the last 10 values of a continous data-aquisition at a fixed point

    Hello,
    I am using a NI-PCI 6259 for generating and aquiring data.
    The other configuration is:
    - LabVIEW 7.1
    - DAQ 7.3
    I need to measure three anaolg channels, and generate an analog output. Additonally I need to read some values over the RS232. The whole activity should repeat every 30ms. To get this, I am using a timed loop at the moment. I generate a clock with counter 0 and read it with counter 1 for the timed loop. Inside the timed loop I start/stop a finite aquisition for the three analog channles and the RS232 reading. The fastest aquiring supported by the RS232 is an iteration every 30ms. Without the analog aquisition the system runs without any dropped loops. By adding the analog aquisition the timed loop dropps 2-5 loops every 1000 iterations.
    I think the problem is the repeated start/stop of the aquisition. Maybe a solution is a continous aquistion by reading out the last 10 values of the buffer every start of the timed loop. But all my tests failed, because of the FIFO design of the buffer. When I start a continous aquisition outside the timed loop and read 10 values inside, I always have the first 10 values of the buffer, not the last ones.
    Does anyone has an idea, how to read loop the last 10 values of a continous aquisition inside a timed ?
    Thanks a lot for your help.
    Best regards,
    Michael
    Attached you will find the actual state of the testprogram. Because the aqusition should be in the last quarter of the generated output value, the values of the loaded waveform (output) are four times resampeled and the clock has four times the speed of the aquisition, which generates a timing event every four clocks.
    Attachments:
    Datenerfassung.zip ‏3047 KB

    To address your main issue you might try using the DAQmx control Task VI right after you call the Timing VI (outside the timed loop) and set its value to commit. This allows for more efficient starts and stops. Some other things I saw in your program which might make it a little easier and use less HW. First, you shouldn't need to create a CO task on ctr0 and then feed it to the timed loop using ctr1. Why don't you just use the Frequency personality of the timed loop? That way you will only use one counter. If you want to use the 2 counter method then to avoid using external wiring as the source for counter 1 in the timing source VI use CTR0/internaloutput. This is an advanced property for the terminal I/O control so you will need to right click on the constant and select I/O filtering. Finally, when you specify your create channel for the AI Voltage why are you doing this in a for loop. You can just have one channel string Dev1/Ai16:18 and that will create all 3 channels with the same information. Hope this helps
    StuartG

  • Make a list with the last 100 added items

    Anybody knows how to have a List that only store the last 100 added items? A kind of a que which always has 100 items.
    Thank you !
    ostense

    I am sure there is a simpler way to do what you are trying to do but ...
    public class LastList extends LinkedList {
        private final int maxSize;
        public LastList(int maxSize) {
            this.maxSize = maxSize;
        public void addFirst(Object o) {
            super.addFirst(o);
            trim();
        public void addLast(Object o) {
            super.addLast(o);
            trim();
        public boolean add(Object o) {
            boolean ret = super.add(o);
            trim();
            return ret;
        public boolean addAll(Collection c) {
            boolean ret = super.addAll(c);
            trim();
            return ret;
        public boolean addAll(int index, Collection c) {
            boolean ret = super.addAll(index, c);
            trim();
            return ret;
        public void add(int index, Object element) {
            super.add(index, element);
            trim();
        private void trim() {
            while(size() > maxSize)
                removeFirst();
    }

  • Get every 10 sec a int.value and need to take the sum of the last 18 values

    Hi,
    i get every 10 sec a int.value and need to take the sum of the last 18 values (3 minutes).
    the programm should work permanently.
    I tried with a 1d-array but didn´t get a result. Could anyone help me?
    Best regards
    kasche

    Use the example in the posted link, then add another shift register for your sum of all elements. Dont add all the elements every time, add them to a running total when they come in. You will need to evaluate how big this number is going to get, however, and decide if you should use an I64 for your running total of all elements. Even this will overflow eventually. 
    So your code would look like that posted by GerdW in the above link, then add a shift register with a starting value of 0. Then add your input value to the value comming from this shift register and send the output to the shift register's output terminal. This creates your running total of all values. The code by GerdW provides your "last 18 elements" total in a very efficient manner, just change the 15 to an 18.
    I have attached a sample bit of code to make it clear. I saved it in LV 8.0 so more people can open it.
    CyberTazer
    Software Systems Engineer
    Attachments:
    Running 18 total.vi ‏11 KB

  • Averaging over the last hour and last eight hours.

    This is fairly simple but I'm not sure what a "good" approach is. Basically I need to track how many times a user has performed an action over the last hour and last eight hours. I'll receive a notification of some sort when they perform this action and could get the current time, but I'm not sure what a fast way of determining how many times this has occurred in a given time period is.
    I was thinking perhaps an array with the time of each in milliseconds and just find the first index that was < 8 hours or < 1 hour ago and then subtract the index from the current size. I think that would be problematic though. To keep the array from continuously growing I'd have to shift everything over to the left which means an expensive arraycopy. Perhaps if I only did the resizing when there were > 20 or elements I no longer care about or something would help, but then I'd have to iterate over 20 elements I don't care about everytime it's calculated, which is once a second.
    Any algorithms that will solve this?

    Here is a method with a granularity of a minute (i.e.
    it only updates the average value every minute - you
    can change it to give whatever granularity you want)
    Keep an array with 60 elements in it. The array
    counts the number of times that the user performed
    the action each minute.
    The array in indexed modulo real time, and you make
    entries based on actual time of day. So when a user
    performs an action at 8:38:45 you increment slot 38.
    Each slot counts the number of actions that took
    place in that particular minute. When the next minute
    rolls around, you move to the next slot, set the
    value to zero (thus throwing out the events that
    happened over an hour ago, and prepare to count the
    new events)
    The sum of the entire array is of course the total
    number of events that have taken place in the last
    hour.
    You do not need to actually run through the array and
    total the events every time you want to calculate the
    average. You can use the fact that you increase the
    total by one every time you get a new event and you
    decrease the total by X everytime you zero out a slot
    that had X for its event count.
    So you can just keep a single value, Total, along
    with your array that goes up by one on every event
    and then drops back a little every minute, when you
    throw out the hour old events.That is probably a good solution to the question I posed, but I realize now I was not thorough or accurate enough in describing the context and requirements. I don't think that will work without a lot of unnecessary memory, but maybe I'm wrong.
    The user action is actually the successful completion of entering a form, a bill to be more precise. I expect this to happen 100-300 times an hour to give an idea of the frequency. Given a period of time, if they've been at it for that period of time or longer I need to find the number of bills completed in that most recent period of time. Otherwise, I need to use what is available to predict what they will reach in that period of time. In other words, if the time period is an hour I need to figure out how many bills were completed in the last hour, but if they've been going for only five minutes I need to predict what they will have completed in an hour including those last five minutes. Then I need to do the same thing for seven hours, using the last seven hours or less of data.
    I guess I'd just have to use a granularity of a minute or less and calculate how many bills over how many minutes and make a prediction on that? I suppose I was hoping for something more precise, but now that I think about it that will probably suffice.
    How would you implement it though? Create a "minute" array of size 60 initially, then when reaching the end of that array adding the total for that array to an "hourly" array (keeps track of bills in that hour) and then start over? I guess then you'd just have to add each from the hourly array to the current total and calculate based upon that. At any given time I'd have the number of bills processed in the last x hours and y minutes, which is enough to calculate how much can be completed at that rate in a given hour or seven hour day.
    I'll try this tomorrow when I get to work, thank you very much I was needlessly complicating it with timestamps. In fact, this inadvertently (or perhaps purposefully?) solves an issue with not calculating time when a user is at lunch or on break. At least I think it does.

  • Obtaining the last n values - possible to do non-procedurally?

    I'm not sure if the following is possible without using PL/SQL instead garden variety SQL.
    I'm looking for the last 4 or less (or some other arbitrary number) of LABVALUES for a PERSON. This is regardless of the time period in which they occur. Eventually I might AVERAGE these or do some other summary operation. The LABDATE might be a standard Oracle date, or might be a number (number of microseconds from 1/1/1960); however, these date forms would NOT be mixed in the same query.
    The base query is:
    SELECT DISTINCT
    PERSON.NAME,
    LAB.VALUE,
    LAB.DATE
    FROM
    PERSON,
    LAB
    WHERE
    PERSON.ID = LAB.ID
    Does this have to be done procedurally or can it just be done as a SELECT statement
    Thanks,
    Will

    Eric, Everything looks good assuming that we can go by Person.Id for order by clause, just couple of things,
    1. William's spec does not have Person_Id column.
    2. William also says he needs last 'n' rows for each Person, however he did not mention whether he passes 'Name' of the Person as a parameter. Following are couple of SQLs, one with Person Name as parameter and another one with out the parameter which brings all the persons with 'n' number of rows for each person.
    /* Please note that I have not used analytical fn here, only because we can get away with out having to use it. Just an alternative ONLY. */
    SELECT Name, Value, Date
    FROM
       (Select P.Id
              , P.Name
              , L.Value
              , L.Date
        From PERSON P, LAB L
        Where P.Id = L.Id
        Group By P.Id, P.Name, L.Value, L.Date
        Order By P.Id Desc)
    WHERE Name = :PersonName -- use Name of Person here as parameter
    AND ROWNUM <= :n; -- number of rows required for the given Person
    /* Please note that I have not used the group by here as PARTITION
    does that for us*/
    SELECT Name, Value, Date
    FROM
       (Select  P.Name
              , L.Value
              , L.Date
              , row_number() over(PARTITION BY P.Name ORDER BY L.Id desc) Rn
       From PERSON P, LAB L
       Where P.Id = L.Id)
    WHERE Rn <= :n; -- number of rows for each personThx,
    SriDHAR

Maybe you are looking for

  • Mail - XI - SAP

    Hi, I am working on following scenario: 1)      Customer sends data in the attachment of Mail (attachement is a tab delimited file) 2)      XI is used as middleware. Mail will be receive in XI and then XI will map the source data into target. 3)     

  • How we use of page number in OBIEE

    Hello, In BI Apps OOTB dashboards I have seen the page number , version number and so on at the footer of dashboard page. How do we get that in OBIEE .? do we have to customize any css for that ? Please advice. OBIv = 11.1.1.6.0 Thanks all for the he

  • Character animation question

    Hi all, i need some help to try to understand which technique was used to do this video "puppet", http://www.youtube.com/watch?v=WRNd6K8kS4M i mean witch techniques i can use to reach this result? Someone tell me that adobe guys done this kind of cha

  • Application Server Redirect one Application to a static web page

    We have an OAS installation that contains two applications. One contains both Portal and Oracle Forms components whilst the second is purely Oracle Forms. We want to redirect users to a static web page if an application is down for maintainance. It h

  • No LED light on front and black screen when trying to start up

    Not sure why started my Mac just like everyday and I noticed it had frozen on start up screen was shaky but froze none the less. I tried to restart with the button on the front and nothing but the hard drive kicking in and the light on the button won