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 are ordered from the highest power to the constant term.
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')creates a continuous-time transfer-function variable with numerator[1 0], denominator[1], andTs = 0.tf('z',Ts)creates a discrete-time variable with a positive sample time orTs = -1for an unspecified 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)stores0for continuous time, a positive discrete sample time, or-1for unspecified discrete time. Nonzero sample times defaultVariableto'z'.- RunMat mode additionally accepts the variable aliases
'p','q','z^-1', and'q^-1', and allowstf('z')to default toTs = 1. - Complex coefficients are accepted and stored as complex row vectors.
- In RunMat mode, logical and typed-integer coefficients enter a checked double-precision model boundary. Typed-integer sample time is gated separately.
- Automatically resident coefficients are gathered through their owning provider. Explicit gpuArray input requires RunMat mode, and the returned model remains host-side.
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. Automatic residency is gathered transparently; explicit gpuArray input is accepted only in RunMat mode, and the returned object is host-side.
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. tf constructs the transfer-function object. Frequency-response helpers such as bode, freqresp, and evalfr are separate functions.
Does tf support MIMO transfer functions?⌄
Not yet. tf currently 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, damp, 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.
Can I use integer coefficients?⌄
RunMat mode accepts all eight integer classes when every coefficient is exactly representable as double. MATLAB-compatible mode uses the documented floating coefficient surface.
What does Ts = -1 mean?⌄
It creates a discrete-time model whose sample time is unspecified. Continuous-time variables still require Ts = 0.
Related Control functions
damp · db · dcgain · feedback · impulse · isstable · lqr · nyquist · pole · pzmap · rlocus · ss · step · stepinfo · zero
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.