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

조회 수: 5 (최근 30일)
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
Angelo De Donato
Angelo De Donato 2023년 4월 23일
Where windowlength is computed on the matlab script as time horizon times sample wind (for instance 600/0.01=60000 points). When the step of the simulation is not fix anymore we don't know how to do.
Paul
Paul 2023년 4월 23일
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.

댓글을 달려면 로그인하십시오.

채택된 답변

Fangjun Jiang
Fangjun Jiang 2023년 4월 23일
  댓글 수: 2
Angelo De Donato
Angelo De Donato 2023년 4월 23일
Thank you for your answer but no, it is not properly the same question. The answer at that question was good since the simulation on simulink was done with a fixed step solver. Now I need the same result but with the possibility of using a variable step size simulation. In case we fix a step size (for instance 0.01), by knowing the desired time horizon (for instance 600s) we easily obtain that the number of points (600/0.01=60000 points) through which the "Moving Average" has to act. Once we calculate it with a matlab script we give to the simulink model the workspace variable obtained. While in this case the step is not fixed anymore. So we don't know how to compute the acting window of the moving average.
Fangjun Jiang
Fangjun Jiang 2023년 4월 24일
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.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Event Functions에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by