tf — Create a SISO transfer-function object from numerator and denominator coefficient vectors.
tf(num, den) creates a scalar-input scalar-output transfer-function object from numeric numerator and denominator coefficient vectors. Coefficients follow MATLAB's polynomial convention: the first entry is the highest-order term and the last entry is the constant term.
Syntax
H = tf(num, den)
H = tf(num, den, Ts)
H = tf(num, den, 'Variable', variable)
H = tf(num, den, 'Ts', Ts)numanddenare numeric scalar, row-vector, or column-vector coefficient inputs. Coefficients are stored using MATLAB's highest-order-term-first polynomial convention.Tsis an optional finite non-negative sample time. Positive sample times default the transfer-function variable to'z'unlessVariableis provided explicitly.Variableaccepts's','p','z','q','z^-1', or'q^-1'. The denominator vector must contain at least one non-zero coefficient.
How tf works
- 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.
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
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.1Selecting 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, and sample-time constraints before constructing the host-side transfer-function object. Unit and integration tests cover continuous and discrete constructors, 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.
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.
Does tf implement step, impulse, or bode?
No. Those functions are not part of this builtin.
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 works, line by line, in Rust.
- View tf.rs on GitHub
- Learn how the 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 — faster, on any GPU, with no license required.
- Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
- Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
- A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.