I want to plot the average of the last 10 points

My program is running at 10 Hz (I have 100ms wait in my main FOR loop), but I want to plot and save data at 1Hz. But since I'm already running 10x faster than my desired plot rate I'd like to average the 10 points which are collected between plots. I'm sure there is a simple straight forward way to do this but I haven't figured it out yet.
Any help would be appreciated.
Ron

rsi77 wrote:
OK, that looks helpful, but I have one other requirement: I want the program to be able to respond to my input (number source) at the higher frequency. As I understand your diagram my number source would be stuck in the loop and the numbers would only be available to the whole program at the slower rate--am I understanding this correctly? So I want to loop through my program 10 times and respond to those 10 numbers, but then take the average of those last ten numbers and plot/write them to chart/file.
Thanks.
You would put the logic to handle the numbers sample by sample inside the inner loop if that were the case. If they need to save data between iterations, use shift registers or feedback nodes. Look at the example altenbach posted as well. Either of these should help get your thinking in the right place in order to tweek out your own solution. Altenbach's solution might be the more efficient of the two, since it only involves 1 loop.

Similar Messages

  • I am trying to get the average of every 10 points in my table...

    I have a table of data and would like to get an output of the average every 10 points. For example, the average of points 1-10, then the average of points 11-20, then 21-30, etc.
    The challenge is that I do not know ahead of time how many points the sensor will collect each run because it depends on some external factor. I have attached a picture with some made-up data to illustrate what my table looks like. In the example I attached, the averages would be (11+34+125+77+44+232+25+213+22+89)/10 and (90+45+77+26+1+22+57+67+360+33)/10.
    My initial attempt used a case structure which found a running average and then reset whenever a multiple of 10 was reached. However, this method does not seem very efficient. Does anyone have any better ideas?
    Solved!
    Go to Solution.
    Attachments:
    sample data.JPG ‏43 KB

    JarleEkanger wrote:
    How about this? Use Delete array subset to extract chunks for averaging, and a shift register to retain the remaining array.
    It is typically not advisable to use "delete from array" in a tight loop. The constant memory reallocations due to array resizing are probably inefficient.
    Here's one simple way to do it..
    (If the number of points is not divisible by 10, the excess tail is discarded. You can easily modify that behavior if desired.)
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    averages of 10.png ‏5 KB
    averages of 10.vi ‏9 KB

  • How long does the average iPod touch last?

    Not the battery, I mean the actuall iPod. How long does the average one last before it dies? How many hours?

    Judging from this support site, the average iPod lasts until it falls into a toilet.
    Each of my first, second, and third generation iPod Touch models are still working flawlessly. That's thousands of hours. Like Macs, they typically become functionally obsolete before any particular hardware failure ends their life.

  • Take the average of the measured values wich cannot be converted from string to number..

    Hello,
    I have a Keithley 182 Digital Nanometer (K182). I am usins it to measure voltage at high temperature. I want K182 to measure 3 times and then take the avarage of collected data.
    1. First problem is, as you can see from picture, string to number conversion. I tried many ways but I couldn't do it. Values as you see 0,00, and once was
    3,98E-3
    0,00
    392,0
    originan values were
    3,98E-3
    3,95E-3
    3,93E-3
    in table, values generally like this.
    2. I need to take avarege. So i need toindez data, then take avarage. So, I have also problem here...
    Could you please help on thic topic. Thanks in advance.
    Attachments:
    string-number.png ‏19 KB
    string-number-panel.png ‏30 KB

    thank you, I will try this solution. Also I want to do one more thing. So, I am collecting data and putting them in to table let say data are like this
    Temp1     Temp2   Volt
    123,3       234,5      ...
    234,4       567,7
    345,6       789,9
    456,7       678,8
    I want to put data with increment like this given below:
    No  Temp1     Temp2   Volt
    1    123,3       234,5      ...
    2    234,4       567,7    
    3    345,6       789,9
    4    456,7       678,8
    there are no exact number of data. the number of data can change from measurement to measurement (1000, 2000, 500 more or less). How can I program this increment in my system.
    My system is include LakeShore 336 temperature conroller and Keithley 182 Nanovoltmeter. I will set the temperature specified value from room temperature wtih specific ramp rate. Meanwhile I will measure the voltage from sample via K182. So, I can measure both temp, and voltage via taking help from u.

  • How to sort a average in the interactive report

    I have a interactive report. The columns are candidate_name, reviewer_name, score.
    each reviewer will have a score for a candidate. There are many candidates. My boss wants to know which candidate get the highest average score. I build an interactive report.
    I can average the score for each candidate_name and break with this column. I don't know if we can sort the average score for each candidate_name column. If we can, how to do this.
    Thanks a lot!

    Not sure if you got an answer for this, but the only way I know how to do it would be to use an analytic function on the query so that the average of the scores is listed as a column. When you have that, then you can sort by it. As of ApEx 3.2.1, you will not be able to create this new column using the interactive reports "Compute" feature. You'll need to build it into the SQL.
    Shane.

  • How to find the average a key figure in bex

    Hi All,
    I have a fey kigure (ZAMOUNT) which is amout field. So if there are 'n' records, I need to calculate the average of the amount field(AVERAGEAMT) for those n records.
    Example:
                         EMPLOYEE      ZAMOUNT        AVERAGEAMT
    record1:         employee1         $5000.00          5000.00
    record2:         employee2         $7000.00          5000.00
    record2:         employee3         $3000.00          5000.00
    So I need to the result something like this.
    (500070003000)/3 =  $5000.00

    HI,
    in the bex analyzer go the key figure for which you want-> right click-> properties i->calculate result as -> average.
    Thanks

  • Calculate the average value

    the data I measured changed rapidly, so i want get the average value of the data
    Do not tell me to use mean.vi , i have already know that.
    and i got an idea which is add the data into an array every time, then sum of all the data value and take the result divide by the number of elements
    but i dont know how to achieve that, anyone can build a simple vi to show me ? thank you
    i have attached my vi which is using mean.vi to calc the average value, you can delete it and using in your way ,  thank you !
    Solved!
    Go to Solution.
    Attachments:
    EN-new.vi ‏274 KB

    Hi I got a similar issue for averaging. I used the mean.vi from the math function but the average is rolling when i run it. I am trying to calculate the average for the data i read to the RT FIFO (which is around 40000 lines).I got the writing part working, however, when i am reading the data, I couldn't get it working. I thought i read the data as a 1-D array, and then pass it to the Mean.vi and then got the result. But seems like the mean is only showing the last data in the array.
    Can someone help me with this??
    Attachments:
    FPGA-vi.png ‏242 KB
    RT-vi.png ‏182 KB
    RT-2mod.vi ‏515 KB

  • How to take the Average of a DATEDIFF column with NULL values?

    I am building an SSRS report that can display the average of a calculated datediff column in dd/hh/mm format with the following formula:
    =Avg(IIF(Fields!LastCorrectedDate.Value is nothing,0, DATEDIFF("n",cdate(Fields!LastCorrectedDate.Value),cdate(Fields!
    LastSignDate.Value)) \(60*24) & ":" & DATEDIFF("n",cdate(Fields!LastCorrectedDate.Value),cdate(Fields!
    LastSignDate.Value)) mod (60*24)\60  & ":" & DATEDIFF("n",cdate(Fields!LastCorrectedDate.Value),cdate(Fields!
    LastSignDate.Value)) mod (60*24) - (((DATEDIFF("n",cdate(Fields!LastCorrectedDate.Value),cdate(Fields!
    LastSignDate.Value)) mod (60*24))\60)*60) ))
    SSRS does not raise any errors with the formula and I have used the same formula for other columns without issue. I have noticed that this column includes null values which I think may be the problem. When the reports runs, it returns #ERROR on the column
    but does not give a reason why.  I am using SSRS report builder with visual basic logic as opposed to embedding SQL. Any help or feedback would be greatly appreciated.

    Hi No Ragrets,
    According to your description, you want to calculate the average for the date time difference. Right?
    In Reporting Services, Avg() function is only available for numeric values. In this scenario, the DateDiff() function to calculate the minutes difference will return a number. So we can do average calculation based on the return values first. Then we format
    it as a time. We have tested this case in our local environment. Please try the following expression:
    =floor(avg(DateDiff("n",Fields!StartDate.Value,Fields!EndDate.Value))) \(24*60) &":"&
    floor(avg(DateDiff("n",Fields!StartDate.Value,Fields!EndDate.Value))/60 mod 24 )&":"&
    floor(avg(DateDiff("n",Fields!StartDate.Value,Fields!EndDate.Value))) mod 60
    The result looks like below:
    If you have any question, please feel free to ask.
    Best Regards,
    Simon Hou

  • Getting the average of a set of numbers, confused by file IO, please help!

    What i need to do is get the average of a set of numbers, the problem is that i am reading these numbers in from files in different directories where each file returns a number, and the average for the directory is the numbers for each file in that directory added together and divided by the number of files in that directory.
    public static HashMap readDir(File path, HashMap map) throws IOException{
            File files[] = path.listFiles();
            float totalForDirectory = 0;
             int common = 0;
             int count = 0;
                    if(files != null && files.length > 0) {
                              for(int i=0; i<files.length; i++) {
                                    if(files.isDirectory()) {
    readDir(files[i], map);
    } else {
    //trying to count the number of files in the directory
    count++;
    totalForDirectory =(total(common, totalF1(), totalF2(files[i])));
    readFile(files[i]);
    //will contain pathname, and the average
    map.put(path.getCanonicalPath(), totalForDirectory);
    return map;
    In the above code, totalForDirectory contains the number for each file, i want to add together the result of this variable for each file, "file[i]" in the directory, and divide that by the number of files in that directory.
    Id appreciate any help
    Thanks

    What you want, It seems to me, is a recursive routine (for directories) which returns both a total and a filecount. Then these can be totalled at each level (togther with the count for each file).
    Probably the best approach is to pass a small object in which the totals are accumulated.
    Define a class something like:
    public class Accumulator {
       int count;
       int total;
       public double mean() {
          return total / count;
      public void add(Accumulator add) {
         count += add.count;
         total += add.total;
       public void add(int numberFromFile) {
          count++;
         total += numberFromFile();
      }Create an instance of this at the start of your scan directory method, and pass it when you call make the recursion. At the end of the scan the method would use the first add method to add it's local totals to the hight level total.
    Obviously you create an Accumulator for the first scan directory call which becomes the grand total.

  • Computing average for the time

    Can any one to help to get the average for the time
    For example
    create table time_avg (time date);
    insert into time_avg (select trunc(sysdate,'hh')+5/24/60 from dual);
    insert into time_avg (select trunc(sysdate,'hh')+10/24/60 from dual);
    insert into time_avg (select trunc(sysdate,'hh')+15/24/60 from dual);
    insert into time_avg (select trunc(sysdate,'hh')+20/24/60 from dual);
    select to_char(time,'hh24miss') from time_avg;
    TO_CHA
    140500
    141000
    141500
    142000
    I want to get the average for the above .

    SQL> INSERT INTO time_avg
      2  SELECT SYSDATE-ROWNUM-1-(rownum/24)
      3  FROM all_objects
      4  WHERE rownum<=10;
    10 rows created.
    SQL> ALTER SESSION SET NLS_DATE_FORMAT='DD-mon-YYYY HH24:MI:SS';
    Session altered.
    SQL> select * from time_avg;
    TIME
    10-may-2006 11:10:22
    09-may-2006 10:10:22
    08-may-2006 09:10:22
    07-may-2006 08:10:22
    06-may-2006 07:10:22
    05-may-2006 06:10:22
    04-may-2006 05:10:22
    03-may-2006 04:10:22
    02-may-2006 03:10:22
    01-may-2006 02:10:22
    10 rows selected.
    SQL> SELECT to_char(trunc(sysdate)+(avg(to_number(to_char(time,'sssss'))))/86400,'hh24:mi:ss')
      2  FROM time_avg
      3  /
    TO_CHAR(
    06:40:22---------------
    Anwar

  • Average of the column in ALV report

    Hi,
      I am working on an ALV report and for one of the column, i am calculating the average with fieldcatalog property do_sum = 'C'.
    I am sorting the output table for 2 fields and whenever I am expanding/compressing the sorted fields the average of the column is changing. Please let me know how do I get this average calculated constant. It should not change when the user collapses/expands on the sorted field.
    Regards
    Rashmi

    The same question has been asked in this thread:
    Compute average of a report column
    I have offered a solution but as I've said it's not great but it may meet your needs.
    Or another forum user may review and be able to suggest a better solution.
    Does the average need to be part of the report?
    Could you calculate it and display it within a page item below the report instead?

  • I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells, find the 10 lowest numbers, then get the average and after that multiply it by .96

    I'm new to Mac and the program/all called Numbers. I'm trying to use both Average and small in the same formula. What's I'm trying to do is take 20 cells in a column,  find the 10 lowest numbers, then get the average and after that multiply it by .96  I used to use Excel and the formula worked fine in that. Here is my Formula
    =(average(small(H201:H220,{1,2,3,4,5,6,7,8,9,10})))*.96
    This formula worked in Excel and when I converted my spreadsheet over to Numbers, this formula no longer works.
    The best that I have been able to do so far is use small in 10 different cells, then get the average of the 10 cells and finally multiply that average by .96  So instead of using 1 cell, I'm using 12 cells to get my answer.
    This is a formula that I will be using all the time. The next cell would be =(average(small(H202:H221,{1,2,3,4,5,6,7,8,9,10})))*.96
    Hoping I explain myself well enough and that someone can help me.
    Thanks

    You can still do it in one cell but it will be more unruly than the Excel array formula.
    =average(small(H201:H220,1),small(H201:H220,2),small(H201:H220,3),...,small(H201:H220,10))*0.96
    where you would, of course, replace the "..." with the remaining six SMALL functions.

  • Getting the average of two cols into third col when user inserts or updates

    I hav a table with three column a,b,c.
    now i have to insert the average of the col a & b into c when user inserts or updates
    any of the row?
    i tried using row level trigger for this but not workin fine..
    can anybody of u give me an idea as how to proceed?
    thanks in advance..

    Sorry to be late to reply....
    actually..for the trigger i used i got a mutating error.
    if there is any other option for doing this,u teel me how.
    i used the followin trigger and placed AT to avoid the mutating error.But still
    create or replace trigger trg_xyz after insert or update of m1,m2
    on xyz for each row
    declare
    v1 number;
    pragma autonomous_transaction;
    begin
    v1 := (:new.m1+:new.m2)/2;
    if inserting then
    update set m3=v1 where m2=:new.m2 and m1=:new.m1;
    elsif updating then
    update set m3=v1 where m2=:new.m2 and m1=:new.m1;
    end if;
    commit;
    end;
    this does not throw any error, but doesnt inserts the value.i checked using dbms_output..i showed the average value for v1..but its not updating..

  • Error in Dimension formula to find the average price

    Hi all,
    I have tried a dimension formula to find the average price of Product.
    if the product is a parent level member then average price should be the average of the list price,other wise it should be the list price itself.
    IIF([PRODUCT].CURRENTMEMBER.PROPERTIES("CALC")="N",[KEYFIGURES].[LISTPRICE],AVG(DESCENDANTS([PRODUCT].CURRENTMEMBER,[KEYFIGURES].[LISTPRICE],LEAVES)))
    While i tried the same i received some strange error , i don know whether its having some dependency on the Customer dimension. since K0030101 is a memebr belonging to CUSTOMER dimension.
    MDX statement error:"Value K0030101 for characteristic /CPMB/U6D7SXT un"
    I'm not sure whether its an error with  the formula i created or any dependancy issue or whether this scenario is possible  using  dimension formulas or not.
    Thanks in advance .
    Anila Mohan

    Hi everyone!
    We are using BPC 7.5 NW SP08 and we've had the same error message while adding a formula to the Account dimension:
    'MDX statement error: "Value 1 for characteristic /CPMB/S9D7Q23 un".
    We then checked in BW for /CPMB/S9D7Q23 and found out that it was the Product dimension.
    The solution for the issue was quite interesting. I had seen in another post that sometimes CALC property was not correctly determined for SP08. The solution proposed was to edit dimension members, clear ParentH1 column, process dimension, re-edit, paste back ParentH1 values and process dimension again. This corrected CALC property problem.
    It also worked for my case. After doing it to Product dimension I tried again to set the formula in Account dimension and it worked!!
    Hope this helps.
    Regards,
    Luigi Laporte

  • How do I change this so the average has a decimal and zero?

    I'm trying to get this so that instead of like 90 I'll get 90.0
    oneString = JOptionPane.showInputDialog("Choose a test score 0-100");
              one = Integer.parseInt(oneString);
              twoString = JOptionPane.showInputDialog("Choose another test score");
              two = Integer.parseInt(twoString);
              threeString = JOptionPane.showInputDialog("Choose another test score");
              three = Integer.parseInt(threeString);
              fourString = JOptionPane.showInputDialog("Choose another test score");
              four = Integer.parseInt(fourString);
              fiveString = JOptionPane.showInputDialog("Choose another test score");
              five = Integer.parseInt(fiveString);
              sixString = JOptionPane.showInputDialog("Choose another test score");
              six = Integer.parseInt(sixString);
              sevenString = JOptionPane.showInputDialog("Choose another test score");
              seven = Integer.parseInt(sevenString);
              eightString = JOptionPane.showInputDialog("Choose another test score");
              eight= Integer.parseInt(eightString);
              nineString = JOptionPane.showInputDialog("Choose another test score");
              nine = Integer.parseInt(nineString);
              tenString = JOptionPane.showInputDialog("Choose another test score");
              ten = Integer.parseInt(tenString);
              elevenString = JOptionPane.showInputDialog("Choose another test score");
              eleven = Integer.parseInt(elevenString);
              twelveString = JOptionPane.showInputDialog("Choose another test score");
              twelve = Integer.parseInt(twelveString);
              thirteenString = JOptionPane.showInputDialog("Choose another test score");
              thirteen = Integer.parseInt(thirteenString);
              sum = (one+two+three+four+five+six+seven+eight+nine+ten+eleven+twelve+thirteen);
              mean = (sum / 13);
              System.out.println("The average of the scores is "+mean);

    I advise you to look at your code and ask yourself if it's efficient. What is you wan to add a few numbers to your program? You'll have to add a lot of lines of code.
    Ah well, here's the answer to your question (partially):
        double sum = (one+two+three+four+five+six+seven+eight+nine+ten+eleven+twelve+thirteen);
        double mean = (sum / 13);
    //...

Maybe you are looking for