Accumulator in Simulink

二次信任 提交于 2019-12-14 03:58:49

问题


I have a MATLAB function block in simulink and for each step simlulink does I want to input a counter with increment 1. Ex: 1st Step -> Acc=1 2nd Step -> Acc=2

I tried using a Count up block + Pulse generator but the time step of simulink is not constant.

Any ideas?


回答1:


A common way to do this is to use a sum and a memory block with an initial condition of 0. It should count steps in both fixed and variable step simulations. In fact I believe this would be build and perform very much like an s-function solution during simulation.




回答2:


Why not just use an integrator block? You can choose with a discreet or continuous integrator block depending on your model type. You can specify the start conditions/value and reset conditions if needed. The image below shows an example of discreet and continuous blocks. Both are just using their default values. To do what you want (adding 1 to the output every step) just define the model sample time as an environment variable (eg sT=0.01) and set the integrator gain to be 1/sT.



来源:https://stackoverflow.com/questions/26770144/accumulator-in-simulink

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!