RunMat
GitHub

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

NameTypeRequiredDefaultDescription
variableStringScalarYesTransfer-function indeterminate ('s', 'p', 'z', 'q', 'z^-1', or 'q^-1').
TsNumericScalarNo0.0Sample time (0 for continuous-time model).
numeratorAnyYesNumerator coefficient vector.
denominatorAnyYesDenominator coefficient vector.
nameStringScalarVariadicOption name ('Variable' or 'Ts').
valueAnyVariadicOption value.

Returns

NameTypeDescription
sysAnySISO transfer-function object.

Errors

IdentifierWhenMessage
RunMat:tf:InvalidArgumentArguments do not match supported tf invocation forms.tf: invalid argument
RunMat:tf:InvalidOptionA name/value option token is unsupported or malformed.tf: invalid option
RunMat:tf:InvalidSampleTimeSample time is not a finite non-negative scalar.tf: sample time must be a finite non-negative scalar

How tf works

  • tf('s') and tf('p') create continuous-time transfer-function variables with numerator [1 0], denominator [1], and Ts = 0.
  • tf('z', Ts), tf('q', Ts), tf('z^-1', Ts), and tf('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 tf object.
  • Returns a lightweight object whose class name is tf.
  • Stores Numerator, Denominator, Variable, Ts, InputDelay, and OutputDelay properties on the object.
  • Uses continuous-time defaults: Variable is 's' and Ts is 0.
  • tf(num, den, Ts) stores a finite non-negative sample time and defaults Variable to 'z'.
  • tf(num, den, 'Variable', variable) accepts variable values 's', 'p', 'z', 'q', 'z^-1', and 'q^-1'.
  • tf(num, den, 'Ts', Ts) or tf(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.
  • tf objects 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.Denominator

Expected 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.Denominator

Expected 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.Ts

Expected output:

H.Variable = 'z'
H.Ts = 0.1

Creating a closed-loop model

s = tf('s');
G = 1/(s + 1);
T = feedback(2*G, 1);
dcgain(T)

Expected output:

ans = 0.6667

Selecting the polynomial variable

H = tf([1 0], [1 2 1], 'Variable', 'p');
H.Variable

Expected 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.

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.

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how tf is executed, line by line, in Rust.

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.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.