Concept page: per-block sample time, sub-rate scheduling, zero-order hold
By default every block in a diagram runs at the model's base step (the sampleTime of the diagram). A diagram can be multi-rate: some blocks run slower than the base step, updating only on their own sample hits.
Per-block sample time
Give a discrete block a SampleTime parameter to run it at that rate. When SampleTime is a multiple N of the base step, the block runs its update only every N samples; between hits its output is held (zero-order hold). A block with no SampleTime, or one less than or equal to the base step, runs every step exactly as before — multi-rate is a pure opt-in extension, so a single-rate diagram is unchanged.
This works the same under the fixed-step engine and under a continuous solver (ode1/ode4/CVODES): in both cases a slower discrete block sub-rates and holds its output between hits.
Example
A unit delay driven by a unit-slope ramp tracks the ramp every step at the base rate; at four times the base step it samples every fourth step, producing a coarse staircase. See Multirate_Demo.m in the module examples.
Related blocks
The rateTransition block is a dedicated sample-and-hold primitive for crossing between two rates at a signal boundary; a per-block SampleTime sets a block's own rate directly.
Current scope
Sub-rate scheduling applies to top-level blocks that hold state between updates (their held output follows from the state). A SampleTime that cannot be honored is reported as an error rather than applied silently: one that is not an integer multiple of the base step, one on a stateless feedthrough block, and one on a block nested inside a subsystem (multi-rate covers only top-level blocks). Code generation honors a per-block SampleTime on unitDelay and difference (the generated C/Rust gates the state advance on the major-step index), and the discrete blocks with their own Ts (zoh, ddelay, dtf, dstateSpace, foh) self-schedule in the generated code; a SampleTime on any other block type is rejected rather than silently ignored. Not yet covered: automatic sample-time propagation across the graph, and output sample-and-hold for stateless feedthrough blocks.
| Version | Description |
|---|---|
| 1.0.0 | initial version |