How do I compute a moving average on a vector based signal using embedded MATLAB function in a way similar to the Digital FIR filter?
5 views (last 30 days)
Show older comments
I would like to perform the following operations using Embedded MATLAB function blocks.
1. I have a vector based signal and I would like to calculate the moving average in a way similar to the digital filter block using embedded MATLAB function.
2. I have a vector based signal and I want to compute an average over every N samples and output it at every Nth sample time.
In either cases, how do I remember previous values (history) of signals from within the embedded MATLAB function?
Accepted Answer
MathWorks Support Team
on 3 Jun 2010
The examples attached make use of embedded MATLAB to work around using delay blocks to calculate moving average on a vector based signal. Persistent variables are used in conjunction with embedded MATLAB to store values/histories of input signals.
1. I have a vector based signal and I would like to calculate the moving average in a way similar to the digital filter block using embedded MATLAB function - Refer to the attached example FINALEXAMPLE2.mdl. In this example, the output of the Embedded MATLAB function is shown to be the same as the digital FIR filter.
2. I have a vector based signal and I want to compute an average over every N samples and output it at every Nth sample time - Refer to the attached example FINALEXAMPLE1.mdl.
0 Comments
More Answers (0)
See Also
Categories
Find more on Statistics and Linear Algebra in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!