Discrete Average on Simulink
28 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 steps time. During these steps the output value is constant and it has to be updated each 600 new steps. How can I do this? Thank you so much.
4 Kommentare
Antworten (2)
Fangjun Jiang
am 23 Feb. 2023
Bearbeitet: Fangjun Jiang
am 23 Feb. 2023
See attachment. Use "window length" of "6" instead of "600" to illustrate.
The build-in "Moving Average" block (it requires "DSP System Toolbox") seems like the right one to use. Need to debug further to see why the "initial condition" of the "Rate Transition" block (It behaves as a zero-order hold block) didn't take effect.
I also tried to use a MATLAB Function block to implement this. It is not too hard as long as you have a clear mind of the logic.
"InitialValue" and "WindowLength" is set in base workspace using the model PreLoadFcn callback.
2 Kommentare
Paul
am 23 Feb. 2023
Bearbeitet: Paul
am 23 Feb. 2023
If I understand the question correctly .....
Use a Discrete FIR Filter block to maintain a running average of 600 samples. Set the Sample Time parameter to the desired value or leave as -1 for inherited if the input signal is already at the desired sample time.
Connect the output of the Discrete FIR Filter block to the input of a Rate Transition Block. Set the Output Port Sample Time Options to Multiple of input port sample time. Set the Sample Time Multiple parameter to 600.
0 Kommentare
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!