How to accumulate a collection of samples data in Simulink?
Show older comments
Is it possible to accumulate samples of data (e.g. 20 samples of data at 0.05 sec sampling rate) in Simulink? I want to use these collected samples in a user-defined Simulink function (F1) to generate a certain output which will be an input to another user-defined function (F2).
Is it possible to use a Finite-state machine framework to control the stateflow in case if all the components are working in a serial manner?
Thank you.
Answers (1)
Altaïr
on 11 Feb 2025
0 votes
To accumulate a signal in Simulink, the Buffer block can be utilized. For example, to accumulate 20 samples of a sine wave with a sample time of 0.05 seconds:

The Buffer block will accumulate the sine wave signal for 1 second (0.05 x 20) and send an array containing the accumulated signal to the scope. More information about the Buffer block can be found here:
Regarding the second question, finite state machines can indeed be represented in Stateflow. In fact, this is one of the primary use cases for Stateflow. For further reading, consider this article:
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!