Main Content

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(s)=s23s4s2+5s+6

    G(s) can be factorized into the zero-pole-gain form as:

    G(s)=(s+1)(s4)(s+2)(s+3).

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

    h(s)=k(sz(1))(sz(2))(sz(m))(sp(1))(sp(2))(sp(n))

    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 hij(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

    Description

    sys = zpk(zeros,poles,gain) creates a continuous-time zero-pole-gain model with 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).

    example

    sys = zpk(zeros,poles,gain,ts) creates a discrete-time zero-pole-gain model with sample time ts. Set ts to -1 or [] to leave the sample time unspecified.

    example

    sys = zpk(zeros,poles,gain,ltiSys) creates a zero-pole-gain model with properties inherited from the dynamic system model ltiSys, including the sample time.

    example

    sys = zpk(m) creates a zero-pole-gain model that represents the static gain, m.

    example

    sys = zpk(___,Name,Value) 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.

    example

    sys = zpk(ltiSys) converts the dynamic system model ltiSys to a zero-pole-gain model.

    example

    sys = zpk(ltiSys,component) converts the specified component of ltiSys to zero-pole-gain model form. Use this syntax only when ltiSys is an identified linear time-invariant (LTI) model such as an idss or an idtf model.

    example

    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.

    example

    z = zpk('z',ts) creates special variable z that you can use in a rational expression to create a discrete-time zero-pole-gain model. To leave the sample time unspecified, set ts input argument to -1.

    example

    Input Arguments

    expand all

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

    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 of the zero-pole-gain model, specified as:

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

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

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

    Sample time, specified as a scalar. Also a property of the zpk object. This input argument sets the initial value of property Ts.

    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.)

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

    expand all

    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

    expand all

    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.

    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.

    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.

    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 ValueFirst-Order Factor (Real Root R)Second-Order Factor (Complex Root pair R=a±jb)
    'roots'(sR)(s2αs+β), where α=2a, β=a2+b2
    'frequency'(1sω0), where ω0=R12ζ(sω0)+(sω0)2, where ω02=a2+b2, ζ=aω0
    'time constant'(1τs), where τ=1R12ζ(τs)+(τs)2, where τ=1ω0, ζ=aτ

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

    sw=z1Ts;RR1Ts,

    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 that the following condition is fulfilled: |z1|<<Ts(ω0<<πTs=Nyquist frequency).

    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'

    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.

    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.

    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.

    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.

    Note

    Changing Ts does not discretize or resample the model. To convert between continuous-time and discrete-time representations, use c2d and d2c. To change the sample time of a discrete-time system, use d2d.

    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.

    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.

    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.

    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.

    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.

    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.

    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.

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

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

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

    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.

    expand all

    stepStep response of dynamic system
    impulseImpulse response plot of dynamic system; impulse response data
    lsimCompute time response simulation data of dynamic system to arbitrary inputs
    bodeBode frequency response of dynamic system
    nyquistNyquist response of dynamic system
    nicholsNichols response of dynamic system
    bandwidthFrequency response bandwidth
    polePoles of dynamic system
    zeroZeros and gain of SISO dynamic system
    pzplotPlot pole-zero map of dynamic system
    marginGain margin, phase margin, and crossover frequencies
    tfTransfer function model
    ssState-space model
    c2dConvert model from continuous to discrete time
    d2cConvert model from discrete to continuous time
    d2dResample discrete-time model
    feedbackFeedback connection of multiple models
    connectBlock diagram interconnections of dynamic systems
    seriesSeries connection of two models
    parallelParallel connection of two models
    pidtunePID tuning algorithm for linear plant model
    rlocusRoot locus of dynamic system
    lqrLinear-Quadratic Regulator (LQR) design
    lqgLinear-Quadratic-Gaussian (LQG) design
    lqiLinear-Quadratic-Integral control
    kalmanDesign Kalman filter for state estimation

    Examples

    collapse all

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

    sys(s)=-2s(s-1-i)(s-1+i)(s-2)Continuous-time zero-pole-gain model

    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.
    

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

    sys(s)=7(z-1)(z-2)(z-3)(z-6)(z-5)(z-4)Discrete-time SISO zero-pole-gain model

    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.
    

    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)=[(s-1)(s+1)(s+2)(s+2+i)(s+2-i)].

    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.
    

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

    sys(z)=[1(z+0.3)z(z+0.3)-(z-2)(z+0.3)3(z+0.3)]Discrete-time MIMO zero-pole-gain model

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

    MATLAB figure

    Notice the input name Force in the title of the step response plot.

    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)=ss2+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.
    

    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)=z-1z2-1.85z+0.9.Discrete-time zero-pole-gain model

    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.
    

    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)=2ss(s+8)andsys2(s)=0.8(s-1)(s+3)(s-5).Two zero-pole-gain models with inherited properties

    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.

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

    m=[2435]MIMO static gain matrix

    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.
    

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

    A=[-2-11-2],B=[112-1],C=[10],D=[01].State-space matrices

    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.
    

    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.
    

    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)=BFu(t)+CDe(t), where BF represents the measured component and CD 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.

    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.

    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)=1s2+0.5s+0.1Zero-pole-gain model

    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