feedback — Form SISO feedback interconnections for transfer-function models.
feedback(sys1, sys2) returns the closed-loop SISO transfer function for negative feedback. The current public MathWorks documentation covers dynamic-system inputs, an optional sign, feed-index forms, and signal-name forms. RunMat currently implements the SISO tf subset with an ordinary double scalar feedback gain; broader scalar, native-single, typed-integer, logical, and resident forms are explicit RunMat extensions.
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 as a gated RunMat-only convenience form.feedback(sys1, sys2)computessys1/(1 + sys1*sys2).feedback(sys1, sys2, +1)computes positive feedback assys1/(1 - sys1*sys2).- An ordinary double scalar
sys2is promoted to a constant transfer function usingsys1's variable and sample time; scalarsys1and scalar/scalar systems are independently gated RunMat extensions. - Typed-integer gains and typed-integer signs accept all eight integer classes only in RunMat extension mode. Gains cross once into the floating/complex coefficient domain, so wide
int64anduint64values can round; signs retain the exact valid set -1 or +1. - Native-single, logical, and resident numeric inputs have separate RunMat-only gates. Resident inputs gather for host assembly, and the result remains a host
tfobject. - 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. Resident numeric gains and signs are a gated RunMat extension, gather before host model assembly, and do 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, extension admission before resident gather or model dispatch, feedback sign, sample-time compatibility, zero-delay support, and transfer-function model shape. Source-local tests cover negative and positive feedback, all eight integer classes, wide-integer floating conversion, logical admission, stable extension identifiers, and resident rejection before provider access; VM workflows cover 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.
Which documented feedback forms are still missing?⌄
The current public MATLAB documentation includes feedin/feedout topology selection and signal-name selection. Those forms require general MIMO and named-I/O infrastructure that RunMat does not yet provide.
Are typed integer gains MATLAB-compatible?⌄
Current public documentation does not establish typed-integer gains or signs. RunMat supports all eight classes as explicit extensions: gains enter floating coefficient arithmetic, while the sign must still be exactly -1 or +1.
Related Control functions
damp · db · dcgain · impulse · isstable · lqr · nyquist · pole · pzmap · rlocus · ss · step · stepinfo · tf · zero
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.