Documentation Center

  • Trial Software
  • Product Updates

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:

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

String specifying the way 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:

where Ts is the sampling 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

String specifying the transfer function display variable. Variable can take the following values:

  • '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 sampling period, 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 sampling period Ts. For example, InputDelay = 3 means a delay of three sampling periods.

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 sampling period 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

Sampling 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 sampling 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 sampling time of a discrete-time system.

Default: 0 (continuous time)

TimeUnit

String representing the unit of the time variable. For continuous-time models, this property represents any time delays in the model. For discrete-time models, it represents the sampling time Ts. Use any of the following values:

  • 'nanoseconds'

  • 'microseconds'

  • 'milliseconds'

  • 'seconds'

  • 'minutes'

  • 'hours'

  • 'days'

  • 'weeks'

  • 'months'

  • 'years'

Changing this property changes the overall system behavior. Use chgTimeUnit to convert between time units without modifying system behavior.

Default: 'seconds'

InputName

Input channel names. Set InputName to a string for single-input model. For a multi-input model, set InputName to a cell array of strings.

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: Empty string '' for all input channels

InputUnit

Input channel units. Use InputUnit to keep track of input signal units. For a single-input model, set InputUnit to a string. For a multi-input model, set InputUnit to a cell array of strings. InputUnit has no effect on system behavior.

Default: Empty string '' 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. Set OutputName to a string for single-output model. For a multi-output model, set OutputName to a cell array of strings.

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 to 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: Empty string '' for all input channels

OutputUnit

Output channel units. Use OutputUnit to keep track of output signal units. For a single-output model, set OutputUnit to a string. For a multi-output model, set OutputUnit to a cell array of strings. OutputUnit has no effect on system behavior.

Default: Empty string '' for all input 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. Set Name to a string to label the system.

Default: ''

Notes

Any text that you want to associate with the system. Set Notes to a string or a cell array of strings.

Default: {}

UserData

Any type of data you wish to associate with system. Set UserData to 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
 
...

Default: []

Examples

Example 1

Create the continuous-time SISO transfer function:

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:

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
 
Sampling 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

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.

load icEngine
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')

More About

expand all

Algorithms

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

See Also

| | | | |

Was this topic helpful?