feedback — Interconnect SISO transfer functions in a feedback loop.
feedback(sys1,sys2) constructs the negative-feedback closed-loop transfer function sys1/(1+sys1*sys2). An optional sign of +1 selects positive feedback, giving sys1/(1-sys1*sys2). Current RunMat support is SISO tf models with compatible sample times and no nonzero delays.
Syntax
sys = feedback(sys1)
sys = feedback(sys1, sys2)
sys = feedback(sys1, sys2, sign)Inputs
sys1- Type
Any- Required
- Yes
- Description
- Forward-path SISO tf object or RunMat scalar gain.
sys2- Type
Any- Required
- No
- Default
1- Description
- Feedback-path SISO tf object or scalar gain.
sign- Type
NumericScalar- Required
- No
- Default
-1- Description
- -1 for negative or +1 for positive feedback.
Returns
sys- Type
Any- Description
- Closed-loop SISO tf object.
Errors
RunMat:feedback:InvalidArgument- When
- Inputs do not match supported invocation forms.
- Message
feedback: invalid argument
RunMat:feedback:InvalidModel- When
- Inputs are not supported SISO transfer-function models or scalar gains.
- Message
feedback: invalid model
RunMat:feedback:InvalidSign- When
- Feedback sign is not -1 or +1.
- Message
feedback: sign must be -1 or +1
Forms and compatibility
The MATLAB-compatible subset accepts a SISO tf object as sys1 and a compatible SISO tf object or ordinary real or complex double scalar gain as sys2; sign is -1 or +1. A scalar sys2 becomes a constant transfer function with sys1's variable and sample time. The one-argument unity-feedback form, scalar sys1, and scalar/scalar form have independent RunMat-only extension gates.
Typed-integer scalar gains and signs, native-single, logical, and resident numeric arguments have separate RunMat-only gates. All eight fixed-width integer classes are admitted as scalar gains or signs; gains cross into binary64 tf coefficients, so wide integers can round. A typed-integer sign must still be exactly -1 or +1. Typed-integer tf coefficients or Ts and logical tf coefficients assigned after construction retain their model-property gates; integer model properties require exact conversion, unlike scalar gains.
Both tf models must have compatible sample times. Nonzero input or output delays are not yet supported. MIMO, state-space, feed-index and signal-name topology forms remain outside the current implementation.
Execution and placement
The operation runs on the host and produces a new host tf object; it has no provider-level GPU kernel and is a fusion boundary. Valid resident scalar gains and signs gather after extension admission. Required resident coefficient properties inside valid tf objects gather through their owner during ordered model parsing; unrelated object properties are not read.
The call can suspend for provider gathers and can throw for unsupported model forms, invalid sign, or failed interconnection. It does not mutate input models or use ambient filesystem, network, UI, randomness, or time services.
Examples
Unity negative feedback
G = tf(2, [1 3]); T = feedback(G, 1); d = T.Denominator; fprintf('d = [%g %g]\n', d(1), d(2));Expected output:
d = [1 5]Positive feedback
G = tf(2, [1 3]); T = feedback(G, 1, +1); d = T.Denominator; fprintf('d = [%g %g]\n', d(1), d(2));Expected output:
d = [1 1]RunMat unity-feedback shorthand
G = tf(2, [1 3]); T = feedback(G); d = T.Denominator;RunMat integer scalar gain
G = tf(2, [1 3]); T = feedback(G, uint8(1)); d = T.Denominator;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 or state-space systems?⌄
Not yet. The current implementation constructs SISO tf interconnections.
Are typed-integer gains MATLAB-compatible?⌄
Their documented parity is unverified. RunMat admits them only in RunMat compatibility mode; conversion to floating tf coefficients can round wide values.
Which topology forms are missing?⌄
Feed-index and signal-name forms require MIMO and named-I/O infrastructure that is not yet supported.
Related Control functions
Source you can read
Every RunMat function's source is public. 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 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.