phyphox Forums

Full Version: How to use movingaverage
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hi,

I am trying to use the movingaverage function and am constantly failing.
I have no clue how that function should work.
Can someone please post a simple example?
My not working code looks like this:
Code:
<phyphox xmlns="https://phyphox.org/xml" version="1.18">
  <title>New Experiment</title>
  <category>No Category</category>
  <data-containers>
    <container size="0">x</container>
    <container size="0">xAvg</container>
  </data-containers>
  <input>
    <sensor type="linear_acceleration">
      <output component="x">x</output>
    </sensor>
  </input>
  <analysis>
    <movingaverage>
      <input as="data">x</input>
      <input as="width" type="value">10</input>
      <output as="data">xAvg</output>
    </movingaverage>
  </analysis>
  <views>
    <view label="New View">
      <value label="xAvg">
        <input>xAvg</input>
      </value>
    </view>
  </views>
</phyphox>
The value field is updated at the rate of the analysis block, so nothing really to see here at about 100 Hz. In order to get a better understanding of what's going on, it makes sense to plot the containers against time. You will observe then that the “current” value is averaged with “width” previous values (a total of 11 data points in your case).

There is a rather common … unintendedness in your .phyphox file: you would like to keep the x data, accordingly
Code:
    <movingaverage>
      <input as="data" keep="true">x</input>
      <input as="width" type="value">10</input>
      <output as="data">xAvg</output>
    </movingaverage>

Without “keep” the x container is cleared when exiting this block. Do not use “append” for xAvg. I still need to find a clever way to optimise taking the moving average, so for the time being better take all recorded data in each run.