Enable block vs atomic block

3 次查看(过去 30 天)
alessandro mutasci
alessandro mutasci 2022-10-20
Good evening,I have a doubt regarding how the enable block and atomic block interact with each other. I'm attaching a small project to let you understand better my problem. I have a clock that enable a subsystem after 9 seconds, image: systemLevel0.png. When the block is enabled, an atomic subsystem with a period of 4 seconds, starts a recursive sum, image: systemLevel1.png, image: systemLevel2.png.
My problem, is that the first sum is at 12 seconds and not as I thought at 13 seconds; it doesn't start when the block is enabled. Could you give me an insight regarding how to solve this problem without using a trigger. In order to have a easier code generation?

回答(1 个)

Fangjun Jiang
Fangjun Jiang 2022-10-21
编辑:Fangjun Jiang 2022-10-21
The atomic subsystem is executed at 4s, 8s, 12s, etc. if enabled.
It is not "after it is enabled (regard this as time 0), then execut at time after 4s, 8s, 12s, etc" as you probably imagined.
Change the threshold value for enable flag to be 1,2,3 and see the effect.
To get what you want, you need to have some time related blocks inside the enabled subsystem. For example, a Pulse generator with period of 4 and pulse width 25%, to enable the atomic subsystem. You will get the desired output, once you set the threshold value to be 13 seconds.

类别

Help CenterFile Exchange 中查找有关 Iterator Subsystems 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by