tf — Create and combine SISO transfer-function model objects.
tf('s') creates a continuous-time transfer-function variable, and tf(num, den) creates scalar-input scalar-output transfer-function objects from numeric coefficient vectors. Coefficients follow MATLAB-compatible highest-order-to-constant polynomial ordering.
Syntax
s = tf('s')
z = tf('z', Ts)
sys = tf(numerator, denominator)
sys = tf(numerator, denominator, Ts)
sys = tf(numerator, denominator, "Variable", variableName)
sys = tf(numerator, denominator, name, value, ...)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
variable | StringScalar | Yes | — | Transfer-function indeterminate ('s', 'p', 'z', 'q', 'z^-1', or 'q^-1'). |
Ts | NumericScalar | No | 0.0 | Sample time (0 for continuous-time model). |
numerator | Any | Yes | — | Numerator coefficient vector. |
denominator | Any | Yes | — | Denominator coefficient vector. |
name | StringScalar | Variadic | — | Option name ('Variable' or 'Ts'). |
value | Any | Variadic | — | Option value. |
Returns
| Name | Type | Description |
|---|---|---|
sys | Any | SISO transfer-function object. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:tf:InvalidArgument | Arguments do not match supported tf invocation forms. | tf: invalid argument |
RunMat:tf:InvalidOption | A name/value option token is unsupported or malformed. | tf: invalid option |
RunMat:tf:InvalidSampleTime | Sample time is not a finite non-negative scalar. | tf: sample time must be a finite non-negative scalar |
RunMat:tf:InvalidVariable | Variable option is not a supported control variable name. | tf: invalid Variable option |
RunMat:tf:InvalidCoefficients | Numerator/denominator coefficients are not valid finite vectors. | tf: invalid coefficients |
RunMat:tf:DenominatorInvalid | Denominator coefficient vector is empty or all zeros. | tf: invalid denominator coefficients |
RunMat:tf:Internal | Internal tensor/object construction failed. | tf: internal error |
How tf works
tf('s')andtf('p')create continuous-time transfer-function variables with numerator[1 0], denominator[1], andTs = 0.tf('z', Ts),tf('q', Ts),tf('z^-1', Ts), andtf('q^-1', Ts)create discrete-time variables with a positive sample time.- Accepts numeric scalar, row-vector, or column-vector numerator coefficients.
- Accepts numeric scalar, row-vector, or column-vector denominator coefficients.
- Normalizes stored numerator and denominator coefficients to row vectors on the returned
tfobject. - Returns a lightweight object whose class name is
tf. - Stores
Numerator,Denominator,Variable,Ts,InputDelay, andOutputDelayproperties on the object. - Uses continuous-time defaults:
Variableis's'andTsis0. tf(num, den, Ts)stores a finite non-negative sample time and defaultsVariableto'z'.tf(num, den, 'Variable', variable)acceptsvariablevalues's','p','z','q','z^-1', and'q^-1'.tf(num, den, 'Ts', Ts)ortf(num, den, 'SampleTime', Ts)stores a finite non-negative sample time.- Complex coefficients are accepted and stored as complex row vectors.
- Logical and integer coefficients are promoted to double precision.
tfobjects overload+,-, unary+, unary-,*,.*,/,./,\,.\,^, and.^for SISO transfer-function algebra with scalar gains.- Transfer-function powers require integer scalar exponents.
- Arithmetic requires compatible sample times and does not support nonzero input or output delays.
GPU memory and residency
tf is a host-side object constructor. gpuArray coefficient inputs are gathered before object construction, and the returned transfer-function object does not live on the GPU.
Examples
Using the transfer-function variable shorthand
s = tf('s');
G = 2.5/(0.4*s^2 + 1.8*s + 1);
G.DenominatorExpected output:
ans = [0.4 1.8 1.0]Creating a first-order continuous-time transfer function
H = tf(20, [1 5]);
class(H)Expected output:
ans = "tf"Creating a second-order transfer function
H = tf([1 2], [1 3 2]);
H.Numerator
H.DenominatorExpected output:
H.Numerator = [1 2]
H.Denominator = [1 3 2]Creating a discrete-time transfer function
H = tf(1, [1 -0.5], 0.1);
H.Variable
H.TsExpected output:
H.Variable = 'z'
H.Ts = 0.1Creating a closed-loop model
s = tf('s');
G = 1/(s + 1);
T = feedback(2*G, 1);
dcgain(T)Expected output:
ans = 0.6667Selecting the polynomial variable
H = tf([1 0], [1 2 1], 'Variable', 'p');
H.VariableExpected output:
H.Variable = 'p'How RunMat validates tf
tf validates coefficient shapes, finite numeric values, supported variable names, sample-time constraints, and SISO arithmetic compatibility before constructing or combining host-side transfer-function objects. Unit and integration tests cover continuous and discrete constructors, variable shorthand, polynomial arithmetic, scalar division by transfer functions, row normalization, option parsing, and invalid denominator or matrix coefficient inputs.
- Implementation: `crates/runmat-runtime/src/builtins/control/tf.rs`
See Correctness & Trust for the full methodology and coverage table.
Using tf with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how tf changes the result.
Run a small tf example, explain the result, then change one input and compare the output.
FAQ
Does tf evaluate the transfer function at frequency points?⌄
No. This implementation only constructs the transfer-function object. Frequency-response helpers such as bode, freqresp, and evalfr are separate Control System Toolbox functions.
Does tf support MIMO transfer functions?⌄
Not yet. This implementation supports scalar-input scalar-output systems created from numeric coefficient vectors.
Can I build models with s = tf('s')?⌄
Yes. Continuous-time variable shorthand and integer powers are supported for common polynomial model construction.
Does tf implement response and stability helpers?⌄
step, impulse, nyquist, stepinfo, feedback, dcgain, pole, and isstable are implemented as separate control builtins.
Can I pass matrices of coefficients?⌄
No. Numerator and denominator inputs must be scalars or vectors.
Can the denominator be all zeros?⌄
No. The denominator coefficient vector must contain at least one non-zero value.
Related Control functions
Open-source implementation
Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how tf is executed, line by line, in Rust.
- View the source for tf 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.