series — Connect two supported dynamic-system models in series.
series(sys1,sys2) connects sys1 upstream of sys2. For transfer functions this is sys2*sys1; for state-space models the result retains the state-space representation and source-ordered dynamics.
Syntax
sys = series(sys1,sys2)
sys = series(sys1,sys2,out1,in2)
sys = series(sys1,sys2,'name')Inputs
sys1- Type
Any- Required
- Yes
- Default
- —
- Description
- Upstream tf or ss model.
sys2- Type
Any- Required
- Yes
- Default
- —
- Description
- Downstream tf or ss model.
out1- Type
Any- Required
- Yes
- Default
- —
- Description
- Distinct upstream output indices.
in2- Type
Any- Required
- Yes
- Default
- —
- Description
- Distinct downstream input indices.
sys1- Type
Any- Required
- Yes
- Default
- —
- Description
- Upstream model.
sys2- Type
Any- Required
- Yes
- Default
- —
- Description
- Downstream model.
name- Type
StringScalar- Required
- Yes
- Default
- —
- Description
- Match uniquely named output and input channels.
Returns
sys- Type
Any- Description
- Cascaded model, with sys1 upstream.
Errors
RunMat:series:InvalidArgument- When
- Input or output form is invalid.
- Message
series: invalid argument
RunMat:series:InvalidModel- When
- Model matrices, channels, or sample times are incompatible.
- Message
series: invalid model
RunMat:series:UnsupportedModel- When
- The current model representation cannot express the requested interconnection.
- Message
series: unsupported model
RunMat:series:Internal- When
- Model result construction fails.
- Message
series: internal error
Models and channels
series(sys1,sys2,out1,in2) connects selected upstream outputs to selected downstream inputs. The distinct positive index vectors must have equal lengths; unconnected upstream outputs and downstream inputs are dropped. Direct tf-by-tf SISO composition retains a tf model; a composition involving an ss model produces an ss model.
series(sys1,sys2,'name') connects uniquely matching nonempty upstream OutputName and downstream InputName entries; it rejects duplicate or absent matches. Homogeneous nonempty tf/ss model arrays of equal shape connect corresponding entries; a scalar supported model may connect to each array entry. A real scalar gain scales every channel of a MIMO ss model. Sample times must match and nonzero delays are unsupported. Mixed tf/ss composition needs a proper real tf realization; complex or improper mixed models are currently unsupported. A scalar complex gain is supported for tf-by-tf SISO composition. Typed-integer scalar gains are a RunMat extension and round at the same binary64 model-arithmetic boundary as tf multiplication and feedback.
Execution
State-space composition is host-side matrix algebra. Required resident model properties are downloaded through their exact owners after validation; no GPU series kernel or fusion route is claimed. The call may suspend and may throw on invalid models or provider failures.
Examples
Cascade transfer functions
g1 = tf(2,[1 1]); g2 = tf([1 2],[1 3]); h = series(g1,g2);Cascade state-space systems
g1 = ss(-1,1,1,0); g2 = ss(-2,1,1,0); h = series(g1,g2);Connect a selected MIMO channel
g1 = ss(-1,[1 2],[3;4],[0 1;2 0]); g2 = ss(-2,[5 6],7,[8 9]); h = series(g1,g2,2,1);Using series with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how series changes the result.
Run a small series example, explain the result, then change one input and compare the output.
FAQ
Which model is upstream?⌄
sys1 is upstream. For SISO transfer functions, series(sys1,sys2) equals sys2*sys1.
Related Control functions
Source you can read
Every RunMat function's source is public. Read exactly how series is executed, line by line, in Rust.
- View the source for series in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/license.
- RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
- Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.