The solution to this problem can be solved using 'Reset clock' block written by Ravi Mravi which is very elegent and can be built out of standard blocks. This would be a clock that would be running from the start but could be set to zero at any point by a trigger. see: http://www.mathworks.com/matlabcentral/fileexchange/5761
Triggering a subsystem to run for set duration
3 次查看(过去 30 天)
显示 更早的评论
Hello, I want to trigger a subsystem that will then run for 0.25 time units (more than once) at points through the simulation but I do not know how to trigger a clock. Can anyone help?
Roger
0 个评论
采纳的回答
更多回答(2 个)
Fangjun Jiang
2011-5-24
I am not fully understand your question. Let's see if this is the case. Set your simulation step size as 0.01 second. Drag a "Pulse Generator" block, set the period as 1 second and the pulse width as 25 (percent). Use the output of the "Pulse Generator" to trig an "Enabled Subsystem". The subsystem will be running every 0.25 second out of 1 second.
MarkB
2011-5-24
Fangjun's approach is probably the best way if the interval between the 0.25 pulses is also known in advance. If it is not, I would recommend using Stateflow instead.
The general idea is that you would still use an "Enabled Subsystem" like above, but in this case, Stateflow would output a Boolean signal to drive it. Inside Stateflow, you could read any relevant inputs, and use them to enter a state that sets the output as "true", only exits after 0.25 (check the documentation for "temporal logic" to see the Stateflow keywords for defining time intervals), and then sets the output to "false" upon exiting the state.
5 个评论
Fangjun Jiang
2011-5-26
The use of Matlab function block is not needed. You could just use a switch block.
另请参阅
类别
在 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!