The Black Box block supports ports that have different sample rates. By default, the sample rate of an output port is the sample rate inherited from the input port (or ports, if the inputs run at the same sample rate). Sometimes, it is necessary to explicitly specify the sample rate of a port (for example., if the output port rate is different than the block's input sample rate).
SysgenPortDescriptor
provides a method called
setRate
that allows you to
explicitly set the rate of a port.
setRate
method is not necessarily
the
Simulink®
sample rate
that the port runs at. Instead, it is a positive integer value
that defines the ratio between the desired port sample period
and the
Simulink®
system
clock period defined by the Model Composer Hub block dialog box. Assume you have a model in which the Simulink
system period value for the model is defined as 2 sec. Also
assume that the example dout
port is assigned a
rate of 3 by invoking the setRate
method as
follows:
dout.setRate(3);
A rate of 3 means that a new sample is generated on the dout
port every 3 Simulink system
periods. Because the Simulink system period is 2 sec, this means the Simulink sample rate of
the port is 3 x 2 = 6 sec.
setConstant
method of
SysgenPortDescriptor
. You can also
define a constant by passing Inf
to the
setRate
method.