Simulink - average and output values

13 views (last 30 days)
marcusbarnet
marcusbarnet on 27 Mar 2018
Answered: Rushil about 17 hours ago
I use simulink to read from a sensor which outputs 10 integers values per second (10 Hz).
I would like to compute the average every 100 samples (each 10 seconds).
What is the best way to acquire the samples for 10 seconds and output the mean? For the moment, I'm using "tapped delay" function, but I do not know if it is working correctly.
I connected the "mean" block to the "tapped delay" block by specifying the "number of delays" to 100 and so I expect to see only 10 outputs after the "mean" block, but the values always changes and so I'm not sure if the output is correct.
Can you help me, please?
Configuration for the tapped delay block:
Configuration for mean block:

Answers (1)

Rushil
Rushil 5 minutes ago
Hi
Using the “tapped delay” block does indeed produce many outputs, that is because it carries the means across in a 'window-like' format. In order to obtain the desired functionality, the “buffer” block can be used alongside the “mean” block. Below are the parameters of the blocks that aid in achieving the same:
  • “buffer” : Output Buffer Size = 100
  • “mean” : Mean over entire input
You may read more about “buffer” at the link below:
Below are images of a sample model and scope output that demonstrate the working of the above:
Example model diagram -
Output from "scope" block (considering the input spans for 30s) -
Hope it allows you to resolve the issue

Categories

Find more on Simulink Functions in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!