Moving average with a time window 600s but using a variable step modeling setting

2 visualizaciones (últimos 30 días)
Hi, I have a problem in Simulink. I should obtain the average value of a signal but I should keep this average value for the next 600 time steps. During these steps the output value is constant and it has to be updated each 600 new steps. Moreover I need to use a variable step for the simulation. Using "Moving Average", it seems not possible to use a variable step setting. How can I do this? Thank you so much.
  4 comentarios
Paul el 23 de Abr. de 2023
My recommendation is to rethink any approach that explicitly relies on the step size of the solver, whether it be variable or fixed. Develop the model to use the sample times that you need to model the system, and then choose an appropriate solver for the model.

Iniciar sesión para comentar.

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 23 de Abr. de 2023
  2 comentarios
Fangjun Jiang
Fangjun Jiang el 24 de Abr. de 2023
In that case, use a MATLAB Function block. Read the Clock time as an input. If the time is within the range, accumulate the signal and count how many times it accumulated. When time is up, calculate the average and provide output and then start the next cycle.

Iniciar sesión para comentar.

Más respuestas (0)


Más información sobre Simulink Functions en Help Center y File Exchange.




Community Treasure Hunt

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

Start Hunting!

Translated by