采样时间作为输入-simulink [英] Sampling time as an input-simulink
问题描述
我正在尝试建立一个函数库,使我可以参数化过滤器和其他函数.在simulink标准模块中,我只能事先设置采样时间,而不能进行输入.关于如何创建此功能有任何想法吗?我的第一种方法是使用条件和时钟来允许该参数存在,但是也无法对时钟进行参数化.
I am trying to make a library of functions that will allow me to parameterize filters and other function. In simulink standard blocks, I am only able to set a sampling time prior, rather than take an input. Is there any ideas on how I can create this? My first approach was to use conditionals and a clock to allow this parameter to exist, but the clock cannot be parameterized either.
谢谢.
推荐答案
执行此操作的唯一方法是将每个块编写为S函数.
The only way to do this is to write each of your blocks as S-Functions.
如果您使用的是m代码,则在setup
方法中,您需要将块采样时间定义为
If you are using m-code then within the setup
method you'll need to define the block sample time as
block.SampleTimes = [-2 0];
然后在output
方法中,您需要通过将新值分配给block.NextTimeHit
来设置下一个采样时间(基于输入信号的值).
可以在此处找到执行此操作的示例:带有抖动的方波
then within the output
method you'll need to set the next sample time (based on the value of the input signal) by assigning the new value into block.NextTimeHit
.
An example of doing this can be found here: A Square Wave with Jitter
通过使用 mdlGetTimeOfNextVarHit 方法.
这篇关于采样时间作为输入-simulink的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!