The Black Box block supports ports that have different sample rates. By default, the output port inherits the sample rate 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 your model defines the Simulink system
period value as 2 secs. 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 generates 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.