dcgain — Evaluate steady-state gain of SISO transfer-function models.
dcgain(sys) computes the low-frequency gain of an LTI model: the transfer-function value at s = 0 for continuous-time models or z = 1 for discrete-time models. RunMat currently implements the SISO tf subset.
Syntax
gain = dcgain(sys)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
sys | Any | Yes | — | SISO tf model. |
Returns
| Name | Type | Description |
|---|---|---|
gain | Any | Steady-state gain evaluated at s=0 for continuous-time or z=1 for discrete-time. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:dcgain:InvalidArgument | Input does not match supported invocation forms. | dcgain: invalid argument |
RunMat:dcgain:InvalidModel | Input system is not a valid SISO tf object. | dcgain: invalid model |
RunMat:dcgain:UnsupportedModel | Model form is not supported by the current implementation. | dcgain: unsupported model |
RunMat:dcgain:Internal | Gain evaluation failed internally. | dcgain: internal error |
How dcgain works
- Current RunMat support is limited to SISO
tfobjects; MATLAB also supports broader LTI model families and MIMO gain matrices. - Returns a real scalar for real-valued gains and a complex scalar for complex-valued gains.
- Continuous-time models are evaluated at zero frequency.
- Discrete-time models are evaluated at
z = 1. - A typed integer array is not a valid
sysinput. Integer coefficients admitted bytfhave already crossed the model constructor's numeric boundary and do not makedcgainan integer-array operation. - The documented DC gain is infinite for systems with integrators. RunMat derives the sign or complex axis from the first nonzero local denominator coefficient at the DC evaluation point, avoiding spurious NaN components while preserving exact pole-zero cancellation as indeterminate.
GPU memory and residency
dcgain returns a host scalar for the currently supported SISO form. A resident numeric array is not a dynamic-system object and is rejected without gather or provider dispatch.
Examples
Continuous-time DC gain
H = tf(2, [1 3]);
dcgain(H)Expected output:
ans = 0.6667Infinite gain of an integrator
H = tf(2, [1 0]);
dcgain(H)Expected output:
ans = InfHow RunMat validates dcgain
dcgain validates the object boundary before provider access and evaluates SISO transfer-function numerator and denominator polynomials at the steady-state point. Tests cover finite gains, signed continuous integrator infinity, discrete integrator infinity, complex-axis singular direction, exact pole-zero cancellation, invalid integer sys inputs, and integer coefficients already admitted by tf; broader LTI families and MIMO gain matrices remain explicit general control-system gaps.
- Implementation: `crates/runmat-runtime/src/builtins/control/dcgain.rs`
See Correctness & Trust for the full methodology and coverage table.
Using dcgain with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how dcgain changes the result.
Run a small dcgain example, explain the result, then change one input and compare the output.
FAQ
Does dcgain simulate a step response?⌄
No. It evaluates the transfer-function polynomials directly at the steady-state point.
Related Control functions
damp · db · feedback · 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 dcgain is executed, line by line, in Rust.
- View the source for dcgain 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.