feedback — Form SISO feedback interconnections for transfer-function models.
feedback(sys1, sys2) returns the closed-loop SISO transfer function for negative feedback. sys2 may be another compatible tf object or a scalar gain.
Syntax
sys = feedback(sys1)
sys = feedback(sys1, sys2)
sys = feedback(sys1, sys2, sign)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
sys1 | Any | Yes | — | Forward-path SISO transfer-function model. |
sys2 | Any | No | 1 | Feedback-path SISO transfer function or scalar gain. |
sign | NumericScalar | No | -1 | -1 for negative feedback or +1 for positive feedback. |
Returns
| Name | Type | Description |
|---|---|---|
sys | Any | Closed-loop SISO transfer-function object. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:feedback:InvalidArgument | Inputs do not match supported feedback invocation forms. | feedback: invalid argument |
RunMat:feedback:InvalidModel | Input systems are not supported SISO transfer-function models. | feedback: invalid model |
RunMat:feedback:InvalidSign | Feedback sign is not -1 or +1. | feedback: sign must be -1 or +1 |
RunMat:feedback:UnsupportedModel | A supported-looking model uses unsupported delays or incompatible sample times. | feedback: unsupported model |
RunMat:feedback:Internal | Closed-loop transfer-function assembly failed. | feedback: internal error |
How feedback works
- Supports real or complex SISO
tfobjects represented by numerator and denominator coefficient vectors. feedback(sys1)uses unity negative feedback.feedback(sys1, sys2)computessys1/(1 + sys1*sys2).feedback(sys1, sys2, +1)computes positive feedback assys1/(1 - sys1*sys2).- Scalar gains are promoted to constant transfer functions using the other operand's variable and sample time.
- Input systems must have compatible sample times.
- Nonzero input or output delays are rejected with a clear unsupported-model diagnostic.
GPU memory and residency
feedback returns a host-side tf object. It does not preserve gpuArray residency.
Examples
Unity negative feedback
s = tf('s');
G = 2/(s + 3);
T = feedback(G, 1);
T.DenominatorExpected output:
ans = [1 5]Positive feedback
G = tf(2, [1 3]);
T = feedback(G, 1, +1);
T.DenominatorExpected output:
ans = [1 1]How RunMat validates feedback
feedback validates argument count, feedback sign, sample-time compatibility, zero-delay support, and transfer-function model shape. Tests cover unity negative feedback, positive feedback, scalar gains, and VM workflows using tf('s').
- Implementation: `crates/runmat-runtime/src/builtins/control/feedback.rs`
See Correctness & Trust for the full methodology and coverage table.
Using feedback with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how feedback changes the result.
Run a small feedback example, explain the result, then change one input and compare the output.
FAQ
Does feedback support MIMO systems?⌄
Not yet. This implementation supports SISO transfer-function objects and scalar gains.
Does it support state-space models?⌄
Not yet. The current model-family support is SISO tf.
Related Control functions
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how feedback is executed, line by line, in Rust.
- View the source for feedback in Rust on GitHub
- Learn how the RunMat runtime works
- Found a bug? Open an issue with a minimal reproduction.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 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.