Skip to main content
v2026.11,986 entries · CC-BY 4.0

tf in MATLAB: Create a Transfer Function (tf Function)

How tf works in MATLAB: three ways to build a transfer function, how to read the display, and getting coefficients back with tfdata.

Written and maintained by CASRAI Editorial Board

Published

On this page

Short answer: in MATLAB, tf creates a transfer function model object. You pass coefficient vectors, sys = tf(numerator,denominator), or you define s = tf('s') and write the model as a rational expression. This guide is for researchers and analysts who need to build a transfer function, read what MATLAB prints, and get the coefficients back out. The commands and displayed output below follow the MathWorks documentation for tf and tfdata, read 2026-11-08.

What tf is used for in research

A transfer function relates the input of a linear system to its output as a ratio of polynomials in s (continuous time) or z (discrete time). In MATLAB, tf is the function that stores such a model as a single object, so that later analysis functions can take it as an argument. The MathWorks reference page for tf is titled “tf – Transfer function model” and lists it under the Control System Toolbox documentation.

The same function answers several phrasings of the question. tf function MATLAB, matlab tf and tf in matlab all refer to tf as described here. For signal processing in MATLAB more broadly, see the CASRAI guide on signal analysis in MATLAB.

Install or access (official source only)

The MathWorks documentation places tf in the Control System Toolbox. It states no separate requirement for basic use of tf; it names other products only for specific features: System Identification Toolbox for identified models, Robust Control Toolbox for uncertain (uss) models, and Parallel Computing Toolbox for the UseParallel option. Get MATLAB and its toolboxes only from MathWorks (mathworks.com/help/control/ref/tf.html). For general MATLAB habits before you start, see MATLAB coding.

Step-by-step: create a transfer function with tf

There are three construction routes. Each produces the same kind of object; choose the one that matches how your equation is written.

Route 1: coefficient vectors (continuous time)

  1. Write the numerator and denominator as row vectors of coefficients in descending powers of s. The polynomial 7s2 + 8s – 9 is entered as [7 8 -9].
  2. Call tf:
    numerator = 1;
    denominator = [2,3,4];
    sys = tf(numerator,denominator)
  3. MATLAB displays 1/(2 s^2 + 3 s + 4) followed by “Continuous-time transfer function.”

Route 2: discrete time with a sample time

  1. Add a third argument, the sample time ts in seconds:
    numerator = [2,0];
    denominator = [4,0,3,-1];
    ts = 0.1;
    sys = tf(numerator,denominator,ts)
  2. MATLAB displays 2 z/(4 z^3 + 3 z - 1), then “Sample time: 0.1 seconds” and “Discrete-time transfer function.”
  3. Setting ts to -1 leaves the sample time unspecified.

Route 3: rational expressions with s or z

  1. Continuous time: define the variable, then write the model as arithmetic:
    s = tf('s');
    sys = s/(s^2 + 2*s + 10)
  2. Discrete time: define z with the sample time:
    ts = 0.1;
    z = tf('z',ts);
    sys = (z - 1)/(z^2 - 1.85*z + 0.9)

The three routes side by side

Route Call Time domain Printed label
Coefficient vectors tf(numerator,denominator) Continuous Continuous-time transfer function.
Coefficient vectors plus sample time tf(numerator,denominator,ts) Discrete Sample time: 0.1 seconds, Discrete-time transfer function.
Variable s s = tf('s'), then an expression in s Continuous Continuous-time transfer function.
Variable z z = tf('z',ts), then an expression in z Discrete Discrete-time transfer function.

The reference page also documents tf(m) for a static gain m and tf(ltiSys) for converting another dynamic system model to a transfer function. For multiple-input, multiple-output (MIMO) models, the numerator and denominator are given as cell arrays.

Output and how to read it

The printed form is a ratio with the highest power first. In the Route 2 example, the numerator vector [2,0] prints as 2 z because the trailing zero is the constant term, and the denominator [4,0,3,-1] prints as 4 z^3 + 3 z - 1 because the zero is the missing z^2 term.

Getting the coefficients back with tfdata

tfdata returns the numerator and denominator of an existing model:

[num,den] = tfdata(sys);
[num,den,ts] = tfdata(sys);
[num,den] = tfdata(sys,'v');

For a single model, num and den are 2-D cell arrays (outputs by inputs), and each cell holds a row vector ordered from the highest to the lowest power of s or z. This is the usual surprise: you must index a cell (num{1}) or display with celldisp, not treat num as a vector. For a single-input, single-output model, the 'v' option returns plain row vectors instead. In the MathWorks discrete example, tfdata returns num{1} = 0 0 2 0, den{1} = 4 0 3 -1 and ts = 0.1000; note that the numerator is padded with leading zeros to the denominator’s length.

Troubleshooting

Wrong powers: the coefficient order

Coefficients run from the highest power to the constant. A missing term needs an explicit zero, as in [4,0,3,-1]. Omitting the zero silently shifts every later coefficient to a different power and the shorter vector is still a valid input.

Unrecognized function or variable ‘tf’

The documentation lists tf under the Control System Toolbox. If MATLAB reports that tf is unrecognized, a likely cause is that this toolbox is not installed or licensed for your session; this is an inference from the documentation, not a statement MathWorks makes about that error message. Check which products your installation has, and consult MathWorks support for your license.

Discrete model prints the wrong time domain

If the output says “Continuous-time transfer function,” you did not pass ts (or use tf('z',ts)). Add the sample time argument.

Using the result as numbers

If a script expects a numeric vector and gets a cell array, switch to tfdata(sys,'v') for a SISO model, as described above.

Free alternatives

Tool Equivalent call What the documentation states
python-control (control.matlab.tf) tf(num, den[, dt]), tf('s'), tf('z') Coefficients are ordered so that [2,3,4] means 2s2 + 3s + 4. dt of 0 is continuous, a positive number is the sampling time, and True is discrete with unspecified time. Can create MIMO systems. tf(sys_ss) converts a state-space system.

The python-control example from its documentation defines s = ct.tf('s') and then G = (s+1)/(s**2+2*s+1), the same rational-expression style as Route 3 above. Its documentation page was read 2026-11-08 at python-control.readthedocs.io. For Python numerical work in a related setting, see NumPy polyfit.

FAQ

What does tf do in MATLAB?

It creates a transfer function model object from numerator and denominator coefficients, from a rational expression in s or z, or by converting another model type.

How do I enter the coefficients?

As row vectors in descending powers. For example 7s2 + 8s – 9 is [7 8 -9].

How do I make a discrete-time transfer function?

Pass the sample time as the third argument, tf(numerator,denominator,ts), or define z = tf('z',ts) and write the expression in z.

How do I get the numerator and denominator back out?

Use [num,den] = tfdata(sys). The outputs are cell arrays; use 'v' for a single-input, single-output model to get row vectors.

Why is MATLAB not recognizing tf?

See the troubleshooting section: tf is documented as part of the Control System Toolbox, so a missing toolbox is one possible cause.

Where do I go for plotting a transfer function?

Plotting is outside the scope of this guide; for general plotting in MATLAB, see MATLAB figures.

Sources (official documentation)

Follow CASRAI

Research-administration guidance, standards updates and independent tool reviews.

Ask CASRAI · free to try

Ask about tf in MATLAB: Create a Transfer Function (tf Function)

Ask your first 2 questions free below. Subscribers get 150 a day for $29 a month.

An AI assistant specialized in research administration. It cites the sources behind every answer, labels web answers and says when it can't answer.

Answers draw on CASRAI's guides and dictionary plus the federal and funder documents we index: Federal Register, Grants.gov, Regulations.gov and UKRI.

Works on this site and inside Claude, Cursor and the AI tools you already use.

Everything CASRAI publishes — this page, the dictionary, the guides and the news — stays free to read, with no account and no card.

Referenced across the research world

University of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logoUniversity of Cambridge logoColumbia University logoCrossref logoUniversity of Edinburgh logoHarvard University logoUniversity of Oxford logoPrinceton University logoStanford School of Medicine logoUniversity College London logoORCID logo
  • University of Cambridge logo
  • Columbia University logo
  • Crossref logo
  • University of Edinburgh logo
  • Harvard University logo
  • University of Oxford logo
  • Princeton University logo
  • Stanford School of Medicine logo
  • University College London logo
  • ORCID logo

View CASRAI adoption →