Triggered subsystems at time t=0
5 次查看(过去 30 天)
显示 更早的评论
Hi all,
I'm dealing with a simulink model, in which I have several blocks that are triggered on their rising edge by a pulse generator block. Everything works fine, except for the first pulse. The subsystem is not triggered at the very beginning of the simulation, but I want it to be triggered. The only way to solve this problem is to slightly delay the pulse generator of some ms, but I cannot do that, since there are several S-Functions with aperiodic NextVarHitTime, for which I cannot add an offset. How can I solve such problem?
0 个评论
回答(3 个)
Jonathan
2013-4-23
The answer is to use an enabled subsystem. Use a detect increase block going to the enable, and then set the initial output as 1.
0 个评论
Fangjun Jiang
2011-4-15
Would a function-call generator block solve your problem?
If you have a pulse generator with a periodic time of 4s and your subsystem is triggered by the rising edge, you can achieve the same by using a function-call generator block with sample time as 4s. Change the trigger type of your subsystem to be function-call.
The subsystem will be triggered every 4s and it is first triggered at t=0.
0 个评论
MarkB
2011-4-21
Unfortunately, this sort of behavior is definitely impossible using only a triggered subsystem. Since the "edge" that triggers the subsystem is, by definition, two samples (either a high followed by a low, or a low followed by a high), it really can't execute on the first simulation step.
I would second Fangjun's recommendation that you use a function-call subsystem with a minor modification: Instead of just having a function-call generator drive the block, you could have a Stateflow chart that outputs function calls drive the block instead. The Stateflow chart allows much more complicated outputs that could allow you to always call the subsystem on the first step, and then have subsequent function calls occur based on more complicated criteria.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Schedule Model Components 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!