问题
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.
Thanks in advance.
回答1:
The only way to do this is to write each of your blocks as S-Functions.
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];
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
A similar thing can be done in a c-mex S-Function by using the mdlGetTimeOfNextVarHit method.
来源:https://stackoverflow.com/questions/30352543/sampling-time-as-an-input-simulink