# Documentation

### This is machine translation

Translated by
Mouse over text to see original. Click the button below to return to the English verison of the page.

# zpk

Create zero-pole-gain model; convert to zero-pole-gain model

## Syntax

sys = zpk(Z,P,K)
sys = zpk(Z,p,k,Ts)
sys = zpk(M)
sys = zpk(Z,p,k,ltisys)
s = zpk('s')
z = zpk('z',Ts)
zsys = zpk(sys)
zsys = zpk(sys, 'measured')
zsys = zpk(sys, 'noise')
zsys = zpk(sys, 'augmented')

## Description

Used zpk to create zero-pole-gain models (zpk model objects), or to convert dynamic systems to zero-pole-gain form.

### Creation of Zero-Pole-Gain Models

sys = zpk(Z,P,K) creates a continuous-time zero-pole-gain model with zeros Z, poles P, and gain(s) K. The output sys is a zpk model object storing the model data.

In the SISO case, Z and P are the vectors of real- or complex-valued zeros and poles, and K is the real- or complex-valued scalar gain:

$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)}$

Set Z or p to [] for systems without zeros or poles. These two vectors need not have equal length and the model need not be proper (that is, have an excess of poles).

To create a MIMO zero-pole-gain model, specify the zeros, poles, and gain of each SISO entry of this model. In this case:

• Z and P are cell arrays of vectors with as many rows as outputs and as many columns as inputs, and K is a matrix with as many rows as outputs and as many columns as inputs.

• The vectors Z{i,j} and P{i,j} specify the zeros and poles of the transfer function from input j to output i.

• K(i,j) specifies the (scalar) gain of the transfer function from input j to output i.

See below for a MIMO example.

sys = zpk(Z,p,k,Ts) creates a discrete-time zero-pole-gain model with sample time Ts (in seconds). Set Ts = -1 or Ts = [] to leave the sample time unspecified. The input arguments Z, P, K are as in the continuous-time case.

sys = zpk(M) specifies a static gain M.

sys = zpk(Z,p,k,ltisys) creates a zero-pole-gain model with properties inherited from the LTI model ltisys (including the sample time).

To create an array of zpk model objects, use a for loop, or use multidimensional cell arrays for Z and P, and a multidimensional array for K.

Any of the previous syntaxes can be followed by property name/property value pairs.

'PropertyName',PropertyValue

Each pair specifies a particular property of the model, for example, the input names or the input delay time. For more information about the properties of zpk model objects, see Properties. Note that

sys = zpk(Z,P,K,'Property1',Value1,...,'PropertyN',ValueN)

is a shortcut for the following sequence of commands.

sys = zpk(Z,P,K)
set(sys,'Property1',Value1,...,'PropertyN',ValueN)

### Zero-Pole-Gain Models as Rational Expressions in s or z

You can also use rational expressions to create a ZPK model. To do so, first type either:

• s = zpk('s') to specify a ZPK model using a rational function in the Laplace variable, s.

• z = zpk('z',Ts) to specify a ZPK model with sample time Ts using a rational function in the discrete-time variable, z.

Once you specify either of these variables, you can specify ZPK models directly as rational expressions in the variable s or z by entering your transfer function as a rational expression in either s or z.

### Conversion to Zero-Pole-Gain Form

zsys = zpk(sys) converts an arbitrary LTI model sys to zero-pole-gain form. The output zsys is a ZPK object. By default, zpk uses zero to compute the zeros when converting from state-space to zero-pole-gain. Alternatively,

zsys = zpk(sys,'inv')

uses inversion formulas for state-space models to compute the zeros. This algorithm is faster but less accurate for high-order models with low gain at s = 0.

### Conversion of Identified Models

An identified model is represented by an input-output equation of the form y(t) = Gu(t) + He(t), where u(t) is the set of measured input channels and e(t) represents the noise channels. If Λ= LL' represents the covariance of noise e(t), this equation can also be written as y(t) = Gu(t) + HLv(t), where cov(v(t)) = I.

zsys = zpk(sys), or zsys = zpk(sys, 'measured') converts the measured component of an identified linear model into the ZPK form. sys is a model of type idss, idproc, idtf, idpoly, or idgrey. zsys represents the relationship between u and y.

zsys = zpk(sys, 'noise') converts the noise component of an identified linear model into the ZPK form. It represents the relationship between the noise input, v(t) and output, y_noise = HL v(t). The noise input channels belong to the InputGroup 'Noise'. The names of the noise input channels are v@yname, where yname is the name of the corresponding output channel. zsys has as many inputs as outputs.

zsys = zpk(sys, 'augmented') converts both the measured and noise dynamics into a ZPK model. zsys has ny+nu inputs such that the first nu inputs represent the channels u(t) while the remaining by channels represent the noise channels v(t). zsys.InputGroup contains 2 input groups, 'measured' and 'noise'. zsys.InputGroup.Measured is set to 1:nu while zsys.InputGroup.Noise is set to nu+1:nu+ny. zsys represents the equation y(t) = [G HL] [u; v].

 Tip   An identified nonlinear model cannot be converted into a ZPK system. Use linear approximation functions such as linearize and linapp.

## Variable Selection

As for transfer functions, you can specify which variable to use in the display of zero-pole-gain models. Available choices include s (default) and p for continuous-time models, and z (default), z-1, q-1 (equivalent to z-1), or q (equivalent to z) for discrete-time models. Reassign the 'Variable' property to override the defaults. Changing the variable affects only the display of zero-pole-gain models.

## Properties

zpk objects have the following properties:

Z

System zeros.

The Z property stores the transfer function zeros (the numerator roots). For SISO models, Z is a vector containing the zeros. For MIMO models with Ny outputs and Nu inputs, Z is a Ny-by-Nu cell array of vectors of the zeros for each input/output pair.

P

System poles.

The P property stores the transfer function poles (the denominator roots). For SISO models, P is a vector containing the poles. For MIMO models with Ny outputs and Nu inputs, P is a Ny-by-Nu cell array of vectors of the poles for each input/output pair.

K

System gains.

The K property stores the transfer function gains. For SISO models, K is a scalar value. For MIMO models with Ny outputs and Nu inputs, K is a Ny-by-Nu matrix storing the gains for each input/output pair.

DisplayFormat

Specifies how the numerator and denominator polynomials are factorized for display purposes.

The numerator and denominator polynomials are each displayed as a product of first- and second-order factors. DisplayFormat controls the display of those factors. DisplayFormat can take the following values:

• 'roots' (default) — Display factors in terms of the location of the polynomial roots.

• '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 written in each display format.

DisplayName ValueFirst-Order Factor (Real Root R)Second-Order Factor (Complex Root pair R = a±jb)
'roots'(sR)(s2αs + β), where α = 2a, β = a2 + b2
'frequency'(1 – s/ω0), where ω0 = R1 – 2ζ(s/ω0) + (s/ω0)2, where ω02 = a2 + b2, ζ = a/ω0
'time constant'(1 – τs), where τ = 1/R1 – 2ζ(τs) + (τs)2, where τ = 1/ω0, ζ =

For discrete-time models, the polynomial factors are written as in continuous time, with the following variable substitutions:

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

where Ts is the sample time. In discrete time, τ and ω0 closely match the time constant and natural frequency of the equivalent continuous-time root, provided |z–1| ≪ Ts (ω0 ≪ π/Ts  = Nyquist frequency).

Default: 'roots'

Variable

Transfer function 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'

The value of Variable only affects the display of zpk models.

Default: 's'

IODelay

Transport delays. IODelay is a numeric array specifying a separate transport delay for each input/output pair.

For continuous-time systems, specify transport delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify transport delays in integer multiples of the sample time, Ts.

For a MIMO system with Ny outputs and Nu inputs, set IODelay to a Ny-by-Nu array. Each entry of this array is a numerical value that represents the transport delay for the corresponding input/output pair. You can also set IODelay to a scalar value to apply the same delay to all input/output pairs.

Default: 0 for all input/output pairs

InputDelay

Input delay for each input channel, specified as a scalar value or numeric vector. For continuous-time systems, specify input delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify input delays in integer multiples of the sample time Ts. For example, InputDelay = 3 means a delay of three sample times.

For a system with Nu inputs, set InputDelay to an Nu-by-1 vector. Each entry of this vector is a numerical value that represents the input delay for the corresponding input channel.

You can also set InputDelay to a scalar value to apply the same delay to all channels.

Default: 0

OutputDelay

Output delays. OutputDelay is a numeric vector specifying a time delay for each output channel. For continuous-time systems, specify output delays in the time unit stored in the TimeUnit property. For discrete-time systems, specify output delays in integer multiples of the sample time Ts. For example, OutputDelay = 3 means a delay of three sampling periods.

For a system with Ny outputs, set OutputDelay to an Ny-by-1 vector, where each entry is a numerical value representing the output delay for the corresponding output channel. You can also set OutputDelay to a scalar value to apply the same delay to all channels.

Default: 0 for all output channels

Ts

Sample time. For continuous-time models, Ts = 0. For discrete-time models, Ts is a positive scalar representing the sampling period. This value is expressed in the unit specified by the TimeUnit property of the model. To denote a discrete-time model with unspecified sample time, set Ts = -1.

Changing this property does not discretize or resample the model. Use c2d and d2c to convert between continuous- and discrete-time representations. Use d2d to change the sample time of a discrete-time system.

Default: 0 (continuous time)

TimeUnit

Units for the time variable, the sample time Ts, and any time delays in the model, specified as one of the following values:

• 'nanoseconds'

• 'microseconds'

• 'milliseconds'

• 'seconds'

• 'minutes'

• 'hours'

• 'days'

• 'weeks'

• 'months'

• 'years'

Changing this property has no effect on other properties, and therefore changes the overall system behavior. Use chgTimeUnit to convert between time units without modifying system behavior.

Default: 'seconds'

InputName

Input channel names, specified as one of the following:

• Character vector — For single-input models, for example, 'controls'.

• Cell array of character vectors — For multi-input models.

Alternatively, use automatic vector expansion to assign input names for multi-input models. For example, if sys is a two-input model, enter:

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.

Input channel names have several uses, including:

• Identifying channels on model display and plots

• Extracting subsystems of MIMO systems

• Specifying connection points when interconnecting models

Default: '' for all input channels

InputUnit

Input channel units, specified as one of the following:

• Character vector — For single-input models, for example, 'seconds'.

• Cell array of character vectors — For multi-input models.

Use InputUnit to keep track of input signal units. InputUnit has no effect on system behavior.

Default: '' for all input channels

InputGroup

Input channel groups. The InputGroup property lets you assign the input channels of MIMO systems into groups and refer to each group by name. Specify input groups as a structure. In this structure, field names are the group names, and field values are the input channels belonging to each group. For example:

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

creates input groups named controls and noise that include input channels 1, 2 and 3, 5, respectively. You can then extract the subsystem from the controls inputs to all outputs using:

sys(:,'controls')

Default: Struct with no fields

OutputName

Output channel names, specified as one of the following:

• Character vector — For single-output models. For example, 'measurements'.

• Cell array of character vectors — For multi-output models.

Alternatively, use automatic vector expansion to assign output names for multi-output models. For example, if sys is a two-output model, enter:

sys.OutputName = 'measurements';

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

You can use the shorthand notation y to refer to the OutputName property. For example, sys.y is equivalent to sys.OutputName.

Output channel names have several uses, including:

• Identifying channels on model display and plots

• Extracting subsystems of MIMO systems

• Specifying connection points when interconnecting models

Default: '' for all output channels

OutputUnit

Output channel units, specified as one of the following:

• Character vector — For single-output models. For example, 'seconds'.

• Cell array of character vectors — For multi-output models.

Use OutputUnit to keep track of output signal units. OutputUnit has no effect on system behavior.

Default: '' for all output channels

OutputGroup

Output channel groups. The OutputGroup property lets you assign the output channels of MIMO systems into groups and refer to each group by name. Specify output groups as a structure. In this structure, field names are the group names, and field values are the output channels belonging to each group. For example:

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

creates output groups named temperature and measurement that include output channels 1, and 3, 5, respectively. You can then extract the subsystem from all inputs to the measurement outputs using:

sys('measurement',:)

Default: Struct with no fields

Name

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

Default: ''

Notes

Any 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'.

Default: {}

UserData

Any type of data you want to associate with system, specified as any MATLAB® data type.

Default: []

SamplingGrid

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

For model arrays that are derived by sampling one or more independent variables, this property tracks the variable values associated with each model in the array. This information appears when you display or plot the model array. Use this information to trace results back to the independent variables.

Set the field names of the data 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 should be numeric and scalar valued, and all arrays of sampled values should match the dimensions of the model array.

For example, suppose you create a 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, suppose you create a 6-by-9 model array, M, by independently sampling two variables, zeta and w. The following code attaches 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 example, the Simulink Control Design™ commands linearize and slLinearizer populate SamplingGrid in this way.

Default: []

## Examples

### Example 1

Create the continuous-time SISO transfer function:

$h\left(s\right)=\frac{-2s}{\left(s-1+j\right)\left(s-1-j\right)\left(s-2\right)}$

Create h(s) as a zpk object using:

h = zpk(0, [1-i 1+i 2], -2);

### Example 2

Specify the following one-input, two-output zero-pole-gain model:

$H\left(z\right)=\left[\begin{array}{c}\frac{1}{z-0.3}\\ \frac{2\left(z+0.5\right)}{\left(z-0.1+j\right)\left(z-0.1-j\right)}\end{array}\right].$

To do this, enter:

Z = {[] ; -0.5};
P = {0.3 ; [0.1+i 0.1-i]};
K = [1 ; 2];
H = zpk(Z,P,K,-1);    % unspecified sample time

### Example 3

Convert the transfer function

h = tf([-10 20 0],[1 7 20 28 19 5]);

to zero-pole-gain form, using:

zpk(h)

This command returns the result:

Zero/pole/gain:
-10 s (s-2)
----------------------
(s+1)^3 (s^2 + 4s + 5)

### Example 4

Create a discrete-time ZPK model from a rational expression in the variable z.

z = zpk('z',0.1);
H = (z+.1)*(z+.2)/(z^2+.6*z+.09)

This command returns the following result:

Zero/pole/gain:
(z+0.1) (z+0.2)
---------------
(z+0.3)^2

Sample time: 0.1

### Example 5

Create a MIMO zpk model using cell arrays of zeros and poles.

Create the two-input, two-output zero-pole-gain model

$H\left(s\right)=\left[\begin{array}{cc}\frac{-1}{s}& \frac{3\left(s+5\right)}{{\left(s+1\right)}^{2}}\\ \frac{2\left({s}^{2}-2s+2\right)}{\left(s-1\right)\left(s-2\right)\left(s-3\right)}& 0\end{array}\right]$

by entering:

Z = {[],-5;[1-i 1+i] []};

P = {0,[-1 -1];[1 2 3],[]};

K = [-1 3;2 0];

H = zpk(Z,P,K);

Use [] as a place holder in Z or P when the corresponding entry of H(s) has no zeros or poles.

### Example 6

Extract the measured and noise components of an identified polynomial model into two separate ZPK models. The former (measured component) can serve as a plant model while the latter can serve as a disturbance model for control system design.

z = iddata(y,u,0.04);
nb = 2; nf = 2; nc = 1; nd = 3; nk = 3;
sys = bj(z, [nb nc nd nf nk]);

sys is a model of the form, y(t) = B/F u(t) + C/D e(t), where B/F represents the measured component and C/D the noise component.

sysMeas = zpk(sys, 'measured')

Alternatively, use can simply use zpk(sys) to extract the measured component.

sysNoise = zpk(sys, 'noise')

collapse all

### Algorithms

zpk uses the MATLAB function roots to convert transfer functions and the functions zero and pole to convert state-space models.