# zpk

Zero-pole-gain model

## Description

Use `zpk`

to create zero-pole-gain models, or to convert dynamic system models to zero-pole-gain
form.

Zero-pole-gain models are a representation of transfer functions in factorized form. For example, consider the following continuous-time SISO transfer function:

$$G\left(s\right)=\frac{{s}^{2}-3s-4}{{s}^{2}+5s+6}$$

`G(s)`

can be factorized into the zero-pole-gain form as:

$$G\left(s\right)=\frac{\left(s+1\right)\left(s-4\right)}{\left(s+2\right)\left(s+3\right)}.$$

A more general representation of the SISO zero-pole-gain model is as follows:

$$h\left(s\right)=k\frac{\left(s-z\left(1\right)\right)\left(s-z\left(2\right)\right)\dots \left(s-z\left(m\right)\right)}{\left(s-p\left(1\right)\right)\left(s-p\left(2\right)\right)\dots \left(s-p\left(n\right)\right)}$$

Here, *z* and *p* are the vectors of
real-valued or complex-valued zeros and poles, and *k* is the real-valued or
complex-valued scalar gain. For MIMO models, each I/O channel is represented by one such
transfer function *h _{ij}*(

*s*).

You can create a zero-pole-gain model object either by specifying the poles, zeros and
gains directly, or by converting a model of another type (such as a state-space model
`ss`

) to zero-pole-gain form.

You can also use `zpk`

to create generalized state-space (`genss`

) models or uncertain state-space (`uss`

(Robust Control Toolbox)) models.

## Creation

### Syntax

### Description

creates a continuous-time zero-pole-gain model with `sys`

= zpk(`zeros`

,`poles`

,`gain`

)`zeros`

and
`poles`

specified as vectors and the scalar value of
`gain`

. The output `sys`

is a
`zpk`

model object storing the model data. Set
`zeros`

or `poles`

to `[]`

for
systems without zeros or poles. These two inputs need not have equal length and the
model need not be proper (that is, have an excess of poles).

sets
Properties of the
zero-pole-gain model using one or more name-value pair arguments to set additional
properties of the model. This syntax works with any of the previous input-argument
combinations.`sys`

= zpk(___,Name,Value)

`s = zpk('s')`

creates a special variable `s`

that you can use in a rational expression to create a continuous-time zero-pole-gain
model. Using a rational expression is sometimes easier and more intuitive than
specifying polynomial coefficients.

### Input Arguments

`zeros`

— Zeros of the zero-pole-gain model

row vector | `Ny`

-by-`Nu`

cell array of row vectors

Zeros of the zero-pole-gain model, specified as:

A row vector for SISO models. For instance, use

`[1,2+i,2-i]`

to create a model with zeros at`s = 1`

,`s = 2+i`

, and`s = 2-i`

. For an example, see Continuous-Time SISO Zero-Pole-Gain Model.An

`Ny`

-by-`Nu`

cell array of row vectors to specify a MIMO zero-pole-gain model, where`Ny`

is the number of outputs, and`Nu`

is the number of inputs. For an example, see Discrete-Time MIMO Zero-Pole-Gain Model.

For instance, if `a`

is `realp`

tunable
parameter with nominal value `3`

, then you can use ```
zeros =
[1 2 a]
```

to create a `genss`

model with zeros at
`s = 1`

and `s = 2`

and a tunable zero at
`s = 3`

.

When you use this input argument to create a `zpk`

model, the
argument sets the initial value of the property Z.

`poles`

— Poles of the zero-pole-gain model

row vector | `Ny`

-by-`Nu`

cell array of row vectors

Poles of the zero-pole-gain model, specified as:

A row vector for SISO models. For an example, see Continuous-Time SISO Zero-Pole-Gain Model.

An

`Ny`

-by-`Nu`

cell array of row vectors to specify a MIMO zero-pole-gain model, where`Ny`

is the number of outputs and`Nu`

is the number of inputs. For an example, see Discrete-Time MIMO Zero-Pole-Gain Model.

Also a property of the `zpk`

object. This input argument sets
the initial value of property P.

`gain`

— Gain of the zero-pole-gain model

scalar | `Ny`

-by-`Nu`

matrix

Gain of the zero-pole-gain model, specified as:

A scalar for SISO models. For an example, see Continuous-Time SISO Zero-Pole-Gain Model.

An

`Ny`

-by-`Nu`

matrix to specify a MIMO zero-pole-gain model, where`Ny`

is the number of outputs and`Nu`

is the number of inputs. For an example, see Discrete-Time MIMO Zero-Pole-Gain Model.

Also a property of the `zpk`

object. This input argument sets
the initial value of property K.

`ts`

— Sample time

scalar

Sample time, specified as a scalar. Also a property of the `zpk`

object. This input argument sets the initial value of property Ts.

`ltiSys`

— Dynamic system

dynamic system model | model array

Dynamic system, specified as a SISO or MIMO dynamic system model or array of dynamic system models. Dynamic systems that you can use include:

Continuous-time or discrete-time numeric LTI models, such as

`tf`

,`zpk`

,`ss`

, or`pid`

models.Generalized or uncertain LTI models such as

`genss`

or`uss`

(Robust Control Toolbox) models. (Using uncertain models requires a Robust Control Toolbox™ license.)The resulting zero-pole-gain model assumes

current values of the tunable components for tunable control design blocks.

nominal model values for uncertain control design blocks.

Identified LTI models, such as

`idtf`

(System Identification Toolbox),`idss`

(System Identification Toolbox),`idproc`

(System Identification Toolbox),`idpoly`

(System Identification Toolbox), and`idgrey`

(System Identification Toolbox) models. To select the component of the identified model to convert, specify`component`

. If you do not specify`component`

,`tf`

converts the measured component of the identified model by default. (Using identified models requires System Identification Toolbox™ software.)An identified nonlinear model cannot be converted into a

`zpk`

model object. You may first use linear approximation functions such as`linearize`

and`linapp`

(This functionality requires System Identification Toolbox software.)

`m`

— Static gain

scalar | matrix

Static gain, specified as a scalar or matrix. Static gain or steady state gain of a system represents the ratio of the output to the input under steady state condition.

`component`

— Component of identified model

`'measured'`

(default) | `'noise'`

| `'augmented'`

Component of identified model to convert, specified as one of the following:

`'measured'`

— Convert the measured component of`sys`

.`'noise'`

— Convert the noise component of`sys`

`'augmented'`

— Convert both the measured and noise components of`sys`

.

`component`

only applies when `sys`

is an
identified LTI model.

For more information on identified LTI models and their measured and noise components, see Identified LTI Models.

### Output Arguments

`sys`

— Output system model

`zpk`

model object | `genss`

model object | `uss`

model object

Output system model, returned as:

A zero-pole-gain (

`zpk`

) model object, when the`zeros`

,`poles`

and`gain`

input arguments contain numeric values.A generalized state-space model (

`genss`

) object, when the`zeros`

,`poles`

and`gain`

input arguments includes tunable parameters, such as`realp`

parameters or generalized matrices (`genmat`

).An uncertain state-space model (

`uss`

) object, when the`zeros`

,`poles`

and`gain`

input arguments includes uncertain parameters. Using uncertain models requires a Robust Control Toolbox license.

## Properties

`Z`

— System zeros

cell array | `Ny`

-by-`Nu`

cell array of row vectors

System zeros, specified as:

A cell array of transfer function zeros or the numerator roots for SISO models.

An

`Ny`

-by-`Nu`

cell array of row vectors of the zeros for each I/O pair in a MIMO model, where`Ny`

is the number of outputs and`Nu`

is the number of inputs.

The values of `Z`

can be either real-valued or
complex-valued.

`P`

— System poles

cell array | `Ny`

-by-`Nu`

cell array of row vectors

System poles, specified as:

A cell array of transfer function poles or the denominator roots for SISO models.

An

`Ny`

-by-`Nu`

cell array of row vectors of the poles for each I/O pair in a MIMO model, where`Ny`

is the number of outputs and`Nu`

is the number of inputs.

The values of `P`

can be either real-valued or
complex-valued.

`K`

— System gains

scalar | `Ny`

-by-`Nu`

matrix

System gains, specified as:

A scalar value for SISO models.

An

`Ny`

-by-`Nu`

matrix storing the gain values for each I/O pair of the MIMO model, where`Ny`

is the number of outputs and`Nu`

is the number of inputs.

The values of `K`

can be either real-valued or complex-valued.

`DisplayFormat`

— Specifies how the numerator and denominator polynomials are factorized for display

`'roots'`

(default) | `'frequency'`

| `'time constant'`

Specifies how the numerator and denominator polynomials are factorized for display, specified as one of the following:

`'roots'`

— Display factors in terms of the location of the polynomial roots.`'roots'`

is the default value of`DisplayFormat`

.`'frequency'`

— Display factors in terms of root natural frequencies*ω*_{0}and damping ratios*ζ*.The

`'frequency'`

display format is not available for discrete-time models with`Variable`

value`'z^-1'`

or`'q^-1'`

.`'time constant'`

— Display factors in terms of root time constants*τ*and damping ratios*ζ*.The

`'time constant'`

display format is not available for discrete-time models with`Variable`

value`'z^-1'`

or`'q^-1'`

.

For continuous-time models, the following table shows how the polynomial factors are arranged in each display format.

`DisplayName` Value | First-Order Factor (Real Root $$R$$) | Second-Order Factor (Complex Root pair $$R=a\pm jb$$) |
---|---|---|

`'roots'` | $$(s-R)$$ | $$({s}^{2}-\alpha s+\beta ),$$ where $$\alpha =2a,\text{}\beta ={a}^{2}+{b}^{2}$$ |

`'frequency'` | $$\left(1-\frac{s}{{\omega}_{0}}\right),$$ where $${\omega}_{0}=R$$ | $$1-2\zeta \left(\frac{s}{{\omega}_{0}}\right)+{\left(\frac{s}{{\omega}_{0}}\right)}^{2},$$ where $${\omega}_{0}{}^{2}={a}^{2}+{b}^{2},\text{}\zeta =\frac{a}{{\omega}_{0}}$$ |

`'time constant'` | $$\left(1-\tau s\right),$$ where $$\tau =\frac{1}{R}$$ | $$1-2\zeta \left(\tau s\right)+{\left(\tau s\right)}^{2},$$ where $$\tau =\frac{1}{{\omega}_{0}},\text{}\zeta =a\tau $$ |

For discrete-time models, the polynomial factors are arranged similar to the continuous-time models, with the following variable substitutions:

$$s\to w=\frac{z-1}{{T}_{s}};\text{\hspace{1em}}R\to \frac{R-1}{{T}_{s}},$$

where *T _{s}* is the sample time. In
discrete-time,

*τ*and

*ω*

_{0}closely match the time constant and natural frequency of the equivalent continuous-time root, provided that the following condition is fulfilled: $$\left|z-1\right|<<{T}_{s}\left({\omega}_{0}<<\frac{\pi}{{T}_{s}}=\text{Nyquistfrequency}\right)$$.

`Variable`

— Zero-pole-gain model display variable

`'s'`

(default) | `'z'`

| `'p'`

| `'q'`

| `'z^-1'`

| `'q^-1'`

Zero-pole-gain model display variable, specified as one of the following:

`'s'`

— Default for continuous-time models`'z'`

— Default for discrete-time models`'p'`

— Equivalent to`'s'`

`'q'`

— Equivalent to`'z'`

`'z^-1'`

— Inverse of`'z'`

`'q^-1'`

— Equivalent to`'z^-1'`

`IODelay`

— Transport delay

`0`

(default) | scalar | `Ny`

-by-`Nu`

array

Transport delay, specified as one of the following:

Scalar — Specify the transport delay for a SISO system or the same transport delay for all input/output pairs of a MIMO system.

`Ny`

-by-`Nu`

array — Specify separate transport delays for each input/output pair of a MIMO system. Here,`Ny`

is the number of outputs and`Nu`

is the number of inputs.

For continuous-time systems, specify transport delays in the time unit specified by
the `TimeUnit`

property. For discrete-time systems, specify transport
delays in integer multiples of the sample time, `Ts`

. For more
information on time delay, see Time Delays in Linear Systems.

`InputDelay`

— Input delay

`0`

(default) | scalar | `Nu`

-by-1 vector

Input delay for each input channel, specified as one of the following:

Scalar — Specify the input delay for a SISO system or the same delay for all inputs of a multi-input system.

`Nu`

-by-1 vector — Specify separate input delays for input of a multi-input system, where`Nu`

is the number of inputs.

For continuous-time systems, specify input delays in the time unit specified by the `TimeUnit`

property. For discrete-time systems, specify input delays in integer multiples of the sample time, `Ts`

.

For more information, see Time Delays in Linear Systems.

`OutputDelay`

— Output delay

`0`

(default) | scalar | `Ny`

-by-1 vector

Output delay for each output channel, specified as one of the following:

Scalar — Specify the output delay for a SISO system or the same delay for all outputs of a multi-output system.

`Ny`

-by-1 vector — Specify separate output delays for output of a multi-output system, where`Ny`

is the number of outputs.

For continuous-time systems, specify output delays in the time unit specified by the `TimeUnit`

property. For discrete-time systems, specify output delays in integer multiples of the sample time, `Ts`

.

For more information, see Time Delays in Linear Systems.

`Ts`

— Sample time

`0`

(default) | positive scalar | `-1`

Sample time, specified as:

`0`

for continuous-time systems.A positive scalar representing the sampling period of a discrete-time system. Specify

`Ts`

in the time unit specified by the`TimeUnit`

property.`-1`

for a discrete-time system with an unspecified sample time.

`TimeUnit`

— Time variable units

`'seconds'`

(default) | `'nanoseconds'`

| `'microseconds'`

| `'milliseconds'`

| `'minutes'`

| `'hours'`

| `'days'`

| `'weeks'`

| `'months'`

| `'years'`

| ...

Time variable units, specified as one of the following:

`'nanoseconds'`

`'microseconds'`

`'milliseconds'`

`'seconds'`

`'minutes'`

`'hours'`

`'days'`

`'weeks'`

`'months'`

`'years'`

Changing `TimeUnit`

has no effect on other properties, but changes the overall system behavior. Use `chgTimeUnit`

to convert between time units without modifying system behavior.

`InputName`

— Input channel names

`''`

(default) | character vector | cell array of character vectors

Input channel names, specified as one of the following:

A character vector, for single-input models.

A cell array of character vectors, for multi-input models.

`''`

, no names specified, for any input channels.

Alternatively, you can assign input names for multi-input models using automatic vector
expansion. For example, if `sys`

is a two-input model, enter the
following.

`sys.InputName = 'controls';`

The input names automatically expand to `{'controls(1)';'controls(2)'}`

.

You can use the shorthand notation `u`

to refer to the `InputName`

property. For example, `sys.u`

is equivalent to `sys.InputName`

.

Use `InputName`

to:

Identify channels on model display and plots.

Extract subsystems of MIMO systems.

Specify connection points when interconnecting models.

`InputUnit`

— Input channel units

`''`

(default) | character vector | cell array of character vectors

Input channel units, specified as one of the following:

A character vector, for single-input models.

A cell array of character vectors, for multi-input models.

`''`

, no units specified, for any input channels.

Use `InputUnit`

to specify input signal units. `InputUnit`

has no effect on system behavior.

`InputGroup`

— Input channel groups

structure

Input channel groups, specified as a structure. Use `InputGroup`

to assign
the input channels of MIMO systems into groups and refer to each group by name. The
field names of `InputGroup`

are the group names and the field values
are the input channels of each group. For example, enter the following to create input
groups named `controls`

and `noise`

that include input
channels `1`

and `2`

, and `3`

and
`5`

, respectively.

sys.InputGroup.controls = [1 2]; sys.InputGroup.noise = [3 5];

You can then extract the subsystem from the `controls`

inputs to all outputs
using the following.

`sys(:,'controls')`

By default, `InputGroup`

is a structure with no fields.

`OutputName`

— Output channel names

`''`

(default) | character vector | cell array of character vectors

Output channel names, specified as one of the following:

A character vector, for single-output models.

A cell array of character vectors, for multi-output models.

`''`

, no names specified, for any output channels.

Alternatively, you can assign output names for multi-output models using automatic vector
expansion. For example, if `sys`

is a two-output model, enter the
following.

`sys.OutputName = 'measurements';`

The output names automatically expand to `{'measurements(1)';'measurements(2)'}`

.

You can also use the shorthand notation `y`

to refer to the `OutputName`

property. For example, `sys.y`

is equivalent to `sys.OutputName`

.

Use `OutputName`

to:

Identify channels on model display and plots.

Extract subsystems of MIMO systems.

Specify connection points when interconnecting models.

`OutputUnit`

— Output channel units

`''`

(default) | character vector | cell array of character vectors

Output channel units, specified as one of the following:

A character vector, for single-output models.

A cell array of character vectors, for multi-output models.

`''`

, no units specified, for any output channels.

Use `OutputUnit`

to specify output signal units. `OutputUnit`

has no effect on system behavior.

`OutputGroup`

— Output channel groups

structure

Output channel groups, specified as a structure. Use `OutputGroup`

to
assign the output channels of MIMO systems into groups and refer to each group by name.
The field names of `OutputGroup`

are the group names and the field
values are the output channels of each group. For example, create output groups named
`temperature`

and `measurement`

that include
output channels `1`

, and `3`

and `5`

,
respectively.

sys.OutputGroup.temperature = [1]; sys.OutputGroup.measurement = [3 5];

You can then extract the subsystem from all inputs to the `measurement`

outputs using the following.

`sys('measurement',:)`

By default, `OutputGroup`

is a structure with no fields.

`Name`

— System name

`''`

(default) | character vector

System name, specified as a character vector. For example, `'system_1'`

.

`Notes`

— User-specified text

`{}`

(default) | character vector | cell array of character vectors

User-specified text that you want to associate with the system, specified as a character vector or cell array of character vectors. For example, `'System is MIMO'`

.

`UserData`

— User-specified data

`[]`

(default) | any MATLAB^{®} data type

User-specified data that you want to associate with the system, specified as any MATLAB data type.

`SamplingGrid`

— Sampling grid for model arrays

structure array

Sampling grid for model arrays, specified as a structure array.

Use `SamplingGrid`

to track the variable values associated with each model in a model array, including identified linear time-invariant (IDLTI) model arrays.

Set the field names of the structure to the names of the sampling variables. Set the field values to the sampled variable values associated with each model in the array. All sampling variables must be numeric scalars, and all arrays of sampled values must match the dimensions of the model array.

For example, you can create an 11-by-1 array of linear models, `sysarr`

, by taking snapshots of a linear time-varying system at times `t = 0:10`

. The following code stores the time samples with the linear models.

` sysarr.SamplingGrid = struct('time',0:10)`

Similarly, you can create a 6-by-9 model array, `M`

, by independently sampling two variables, `zeta`

and `w`

. The following code maps the `(zeta,w)`

values to `M`

.

[zeta,w] = ndgrid(<6 values of zeta>,<9 values of w>) M.SamplingGrid = struct('zeta',zeta,'w',w)

When you display `M`

, each entry in the array includes the corresponding `zeta`

and `w`

values.

M

M(:,:,1,1) [zeta=0.3, w=5] = 25 -------------- s^2 + 3 s + 25 M(:,:,2,1) [zeta=0.35, w=5] = 25 ---------------- s^2 + 3.5 s + 25 ...

For model arrays generated by linearizing a Simulink^{®} model at multiple parameter values or operating points, the software populates `SamplingGrid`

automatically with the variable values that correspond to each entry in the array. For instance, the Simulink
Control Design™ commands `linearize`

(Simulink Control Design) and `slLinearizer`

(Simulink Control Design) populate `SamplingGrid`

automatically.

By default, `SamplingGrid`

is a structure with no fields.

## Object Functions

The following lists contain a representative subset of the functions you can use with
`zpk`

models. In general, any function applicable to Dynamic System Models is
applicable to a `zpk`

object.

### Linear Analysis

`step` | Step response of dynamic system |

`impulse` | Impulse response plot of dynamic system; impulse response data |

`lsim` | Compute time response simulation data of dynamic system to arbitrary inputs |

`bode` | Bode frequency response of dynamic system |

`nyquist` | Nyquist response of dynamic system |

`nichols` | Nichols response of dynamic system |

`bandwidth` | Frequency response bandwidth |

### Stability Analysis

### Model Transformation

### Model Interconnection

## Examples

### Continuous-Time SISO Zero-Pole-Gain Model

For this example, consider the following continuous-time SISO zero-pole-gain model:

$$sys(s)=\frac{-2s}{(s-1-i)(s-1+i)(s-2)}$$

Specify the zeros, poles and gain, and create the SISO zero-pole-gain model.

zeros = 0; poles = [1-1i 1+1i 2]; gain = -2; sys = zpk(zeros,poles,gain)

sys = -2 s -------------------- (s-2) (s^2 - 2s + 2) Continuous-time zero/pole/gain model.

### Discrete-Time SISO Zero-Pole-Gain Model

For this example, consider the following SISO discrete-time zero-pole-gain model with 0.1s sample time:

$$sys(s)=\frac{7(z-1)(z-2)(z-3)}{(z-6)(z-5)(z-4)}$$

Specify the zeros, poles, gains and the sample time, and create the discrete-time SISO zero-pole-gain model.

zeros = [1 2 3]; poles = [6 5 4]; gain = 7; ts = 0.1; sys = zpk(zeros,poles,gain,ts)

sys = 7 (z-1) (z-2) (z-3) ------------------- (z-6) (z-5) (z-4) Sample time: 0.1 seconds Discrete-time zero/pole/gain model.

### Concatenate SISO Zero-Pole-Gain Models into a MIMO Zero-Pole-Gain Model

In this example, you create a MIMO zero-pole-gain model by concatenating SISO zero-pole-gain models. Consider the following single-input, two-output continuous-time zero-pole-gain model:

$$sys(s)=\left[\begin{array}{c}\frac{(s-1)}{(s+1)}\\ \frac{(s+2)}{(s+2+i)(s+2-i)}\end{array}\right].$$

Specify the MIMO zero-pole-gain model by concatenating the SISO entries.

zeros1 = 1; poles1 = -1; gain = 1; sys1 = zpk(zeros1,poles1,gain)

sys1 = (s-1) ----- (s+1) Continuous-time zero/pole/gain model.

zeros2 = -2; poles2 = [-2+1i -2-1i]; sys2 = zpk(zeros2,poles2,gain)

sys2 = (s+2) -------------- (s^2 + 4s + 5) Continuous-time zero/pole/gain model.

sys = [sys1;sys2]

sys = From input to output... (s-1) 1: ----- (s+1) (s+2) 2: -------------- (s^2 + 4s + 5) Continuous-time zero/pole/gain model.

### Discrete-Time MIMO Zero-Pole-Gain Model

Create a zero-pole-gain model for the discrete-time, multi-input, multi-output model:

$$sys\left(z\right)=\left[\begin{array}{cc}\frac{1}{(z+0.3)}& \frac{z}{(z+0.3)}\\ \frac{-(z-2)}{(z+0.3)}& \frac{3}{(z+0.3)}\end{array}\right]$$

with sample time `ts = 0.2`

seconds.

Specify the zeros and poles as cell arrays and the gains as an array.

zeros = {[] 0;2 []}; poles = {-0.3 -0.3;-0.3 -0.3}; gain = [1 1;-1 3]; ts = 0.2;

Create the discrete-time MIMO zero-pole-gain model.

sys = zpk(zeros,poles,gain,ts)

sys = From input 1 to output... 1 1: ------- (z+0.3) - (z-2) 2: ------- (z+0.3) From input 2 to output... z 1: ------- (z+0.3) 3 2: ------- (z+0.3) Sample time: 0.2 seconds Discrete-time zero/pole/gain model.

### Specify Input Names for Zero-Pole-Gain Model

Specify the zeros, poles and gain along with the sample time and create the zero-pole-gain model, specifying the state and input names using name-value pairs.

zeros = 4; poles = [-1+2i -1-2i]; gain = 3; ts = 0.05; sys = zpk(zeros,poles,gain,ts,'InputName','Force')

sys = From input "Force" to output: 3 (z-4) -------------- (z^2 + 2z + 5) Sample time: 0.05 seconds Discrete-time zero/pole/gain model.

The number of input names must be consistent with the number of zeros.

Naming the inputs and outputs can be useful when dealing with response plots for MIMO systems.

step(sys)

Notice the input name `Force`

in the title of the step response plot.

### Continuous-Time Zero-Pole-Gain Model Using Rational Expression

For this example, create a continuous-time zero-pole-gain model using rational expressions. Using a rational expression can sometimes be easier and more intuitive than specifying poles and zeros.

Consider the following system:

$$sys(s)=\frac{s}{{s}^{2}+2s+10}.$$

To create the transfer function model, first specify `s`

as a `zpk`

object.

`s = zpk('s')`

s = s Continuous-time zero/pole/gain model.

Create the zero-pole-gain model using s in the rational expression.

sys = s/(s^2 + 2*s + 10)

sys = s --------------- (s^2 + 2s + 10) Continuous-time zero/pole/gain model.

### Discrete-Time Zero-Pole-Gain Model Using Rational Expression

For this example, create a discrete-time zero-pole-gain model using a rational expression. Using a rational expression can sometimes be easier and more intuitive than specifying poles and zeros.

Consider the following system:

$$sys(z)=\frac{z-1}{{z}^{2}-1.85z+0.9}.$$

To create the zero-pole-gain model, first specify `z`

as a `zpk`

object and the sample time `ts`

.

```
ts = 0.1;
z = zpk('z',ts)
```

z = z Sample time: 0.1 seconds Discrete-time zero/pole/gain model.

Create the zero-pole-gain model using `z`

in the rational expression.

sys = (z - 1) / (z^2 - 1.85*z + 0.9)

sys = (z-1) ------------------- (z^2 - 1.85z + 0.9) Sample time: 0.1 seconds Discrete-time zero/pole/gain model.

### Zero-Pole-Gain Model with Inherited Properties

For this example, create a zero-pole-gain model with properties inherited from another zero-pole-gain model. Consider the following two zero-pole-gain models:

$$sys1(s)=\frac{2s}{s(s+8)}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}and\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}\phantom{\rule{0.2777777777777778em}{0ex}}sys2(s)=\frac{0.8(s-1)}{(s+3)(s-5)}.$$

For this example, create `sys1`

with the `TimeUnit`

and `InputDelay`

property set to '`minutes`

'.

zero1 = 0; pole1 = [0;-8]; gain1 = 2; sys1 = zpk(zero1,pole1,gain1,'TimeUnit','minutes','InputUnit','minutes')

sys1 = 2 s ------- s (s+8) Continuous-time zero/pole/gain model.

propValues1 = [sys1.TimeUnit,sys1.InputUnit]

`propValues1 = `*1x2 cell*
{'minutes'} {'minutes'}

Create the second zero-pole-gain model with properties inherited from `sys1`

.

zero = 1; pole = [-3,5]; gain2 = 0.8; sys2 = zpk(zero,pole,gain2,sys1)

sys2 = 0.8 (s-1) ----------- (s+3) (s-5) Continuous-time zero/pole/gain model.

propValues2 = [sys2.TimeUnit,sys2.InputUnit]

`propValues2 = `*1x2 cell*
{'minutes'} {'minutes'}

Observe that the zero-pole-gain model `sys2`

has that same properties as `sys1`

.

### Static Gain MIMO Zero-Pole-Gain Model

Consider the following two-input, two-output static gain matrix `m`

:

$$m=\left[\begin{array}{cc}2& 4\\ 3& 5\end{array}\right]$$

Specify the gain matrix and create the static gain zero-pole-gain model.

```
m = [2,4;...
3,5];
sys1 = zpk(m)
```

sys1 = From input 1 to output... 1: 2 2: 3 From input 2 to output... 1: 4 2: 5 Static gain.

You can use static gain zero-pole-gain model `sys1`

obtained above to cascade it with another zero-pole-gain model.

sys2 = zpk(0,[-1 7],1)

sys2 = s ----------- (s+1) (s-7) Continuous-time zero/pole/gain model.

sys = series(sys1,sys2)

sys = From input 1 to output... 2 s 1: ----------- (s+1) (s-7) 3 s 2: ----------- (s+1) (s-7) From input 2 to output... 4 s 1: ----------- (s+1) (s-7) 5 s 2: ----------- (s+1) (s-7) Continuous-time zero/pole/gain model.

### Convert State-Space Model to Zero-Pole-Gain Model

For this example, compute the zero-pole-gain model of the following state-space model:

$$A=\left[\begin{array}{cc}-2& -1\\ 1& -2\end{array}\right],\phantom{\rule{1em}{0ex}}B=\left[\begin{array}{cc}1& 1\\ 2& -1\end{array}\right],\phantom{\rule{1em}{0ex}}C=\left[\begin{array}{cc}1& 0\end{array}\right],\phantom{\rule{1em}{0ex}}D=[\phantom{\rule{0.1em}{0ex}}\begin{array}{cc}0& 1\end{array}].$$

Create the state-space model using the state-space matrices.

A = [-2 -1;1 -2]; B = [1 1;2 -1]; C = [1 0]; D = [0 1]; ltiSys = ss(A,B,C,D);

Convert the state-space model `ltiSys`

to a zero-pole-gain model.

sys = zpk(ltiSys)

sys = From input 1 to output: s -------------- (s^2 + 4s + 5) From input 2 to output: (s^2 + 5s + 8) -------------- (s^2 + 4s + 5) Continuous-time zero/pole/gain model.

### Array of Zero-Pole-Gain Models

You can use a `for`

loop to specify an array of zero-pole-gain models.

First, pre-allocate the zero-pole-gain model array with zeros.

sys = zpk(zeros(1,1,3));

The first two indices represent the number of outputs and inputs for the models, while the third index is the number of models in the array.

Create the zero-pole-gain model array using a rational expression in the `for`

loop.

s = zpk('s'); for k = 1:3 sys(:,:,k) = k/(s^2+s+k); end sys

sys(:,:,1,1) = 1 ------------- (s^2 + s + 1) sys(:,:,2,1) = 2 ------------- (s^2 + s + 2) sys(:,:,3,1) = 3 ------------- (s^2 + s + 3) 3x1 array of continuous-time zero/pole/gain models.

### Extract Zero-Pole-Gain Models from Identified Model

For this example, extract the measured and noise components of an identified polynomial model into two separate zero-pole-gain models.

Load the Box-Jenkins polynomial model `ltiSys`

in `identifiedModel.mat`

.

load('identifiedModel.mat','ltiSys');

`ltiSys`

is an identified discrete-time model of the form: $$y(t)=\frac{B}{F}u(t)+\frac{C}{D}e(t)$$, where $$\frac{B}{F}$$ represents the measured component and $$\frac{C}{D}$$ the noise component.

Extract the measured and noise components as zero-pole-gain models.

`sysMeas = zpk(ltiSys,'measured') `

sysMeas = From input "u1" to output "y1": -0.14256 z^-1 (1-1.374z^-1) z^(-2) * ----------------------------- (1-0.8789z^-1) (1-0.6958z^-1) Sample time: 0.04 seconds Discrete-time zero/pole/gain model.

`sysNoise = zpk(ltiSys,'noise')`

sysNoise = From input "v@y1" to output "y1": 0.045563 (1+0.7245z^-1) -------------------------------------------- (1-0.9658z^-1) (1 - 0.0602z^-1 + 0.2018z^-2) Input groups: Name Channels Noise 1 Sample time: 0.04 seconds Discrete-time zero/pole/gain model.

The measured component can serve as a plant model, while the noise component can be used as a disturbance model for control system design.

### Zero-Pole-Gain Model with Input and Output Delay

For this example, create a SISO zero-pole-gain model with an input delay of 0.5 seconds and an output delay of 2.5 seconds.

zeros = 5; poles = [7+1i 7-1i -3]; gains = 1; sys = zpk(zeros,poles,gains,'InputDelay',0.5,'OutputDelay',2.5)

sys = (s-5) exp(-3*s) * ---------------------- (s+3) (s^2 - 14s + 50) Continuous-time zero/pole/gain model.

You can also use the `get`

command to display all the properties of a MATLAB object.

get(sys)

Z: {[5]} P: {[3x1 double]} K: 1 DisplayFormat: 'roots' Variable: 's' IODelay: 0 InputDelay: 0.5000 OutputDelay: 2.5000 InputName: {''} InputUnit: {''} InputGroup: [1x1 struct] OutputName: {''} OutputUnit: {''} OutputGroup: [1x1 struct] Notes: [0x1 string] UserData: [] Name: '' Ts: 0 TimeUnit: 'seconds' SamplingGrid: [1x1 struct]

For more information on specifying time delay for an LTI model, see Specifying Time Delays.

### Control Design Using Zero-Pole-Gain Models

For this example, design a 2-DOF PID controller with a target bandwidth of 0.75 rad/s for a system represented by the following zero-pole-gain model:

$$sys(s)=\frac{1}{{s}^{2}+0.5s+0.1}$$

Create a zero-pole-gain model object `sys`

using the `zpk`

command.

zeros = []; poles = [-0.25+0.2i;-0.25-0.2i]; gain = 1; sys = zpk(zeros,poles,gain)

sys = 1 --------------------- (s^2 + 0.5s + 0.1025) Continuous-time zero/pole/gain model.

Using the target bandwidth, use `pidtune`

to generate a 2-DOF controller.

```
wc = 0.75;
C2 = pidtune(sys,'PID2',wc)
```

C2 = 1 u = Kp (b*r-y) + Ki --- (r-y) + Kd*s (c*r-y) s with Kp = 0.512, Ki = 0.0975, Kd = 0.574, b = 0.38, c = 0 Continuous-time 2-DOF PID controller in parallel form.

Using the type `'PID2'`

causes `pidtune`

to generate a 2-DOF controller, represented as a `pid2`

object. The display confirms this result. The display also shows that `pidtune`

tunes all controller coefficients, including the setpoint weights `b`

and `c`

, to balance performance and robustness.

For interactive PID tuning in the Live Editor, see the Tune PID Controller Live Editor task. This task lets you interactively design a PID controller and automatically generates MATLAB code for your live script.

For interactive PID tuning in a standalone app, use PID Tuner. See PID Controller Design for Fast Reference Tracking for an example of designing a controller using the app.

## Algorithms

`zpk`

uses the MATLAB function `roots`

to convert transfer functions and the
functions `zero`

and `pole`

to convert state-space models.

## Version History

**Introduced before R2006a**

## MATLAB Command

You clicked a link that corresponds to this MATLAB command:

Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.

Select a Web Site

Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .

You can also select a web site from the following list:

## How to Get Best Site Performance

Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.

### Americas

- América Latina (Español)
- Canada (English)
- United States (English)

### Europe

- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)

- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)