Extract Model Coefficients

Functions for Extracting Model Coefficients

Control System Toolbox™ software includes several commands for extracting model coefficients such as transfer function numerator and denominator coefficients, state-space matrices, and proportional-integral-derivative (PID) gains.

The following commands are available for data extraction.

tfdataExtract transfer function coefficients
zpkdataExtract zero and pole locations and system gain
ssdataExtract state-space matrices
dssdataExtract descriptor state-space matrices
frdataExtract frequency response data from frd model
piddataExtract parallel-form PID data
pidstddataExtract standard-form PID data
getAccess all model property values

Extracting Coefficients of Different Model Type

When you use a data extraction command on a model of a different type, the software computes the coefficients of the target model type. For example, if you use zpkdata on a ss model, the software converts the model to zpk form and returns the zero and pole locations and system gain.

Extract Numeric Model Data and Time Delay

This example shows how to extract transfer function numerator and denominator coefficients using tfdata.

  1. Create a first-order plus dead time transfer function model.

     H = exp(-2.5*s)/(s+12);
  2. Extract the numerator and denominator coefficients.

    [num,den] = tfdata(H,'v')

    The variables num and den are numerical arrays. Without the 'v' flag, tfdata returns cell arrays.

      Note:   For SISO transfer function models, you can also extract coefficients using:

      num = H.num{1};
      den = H.den{1};
  3. Extract the time delay.

    1. Determine which property of H contains the time delay.

      In a SISO tf model, you can express a time delay as an input delay, an output delay, or a transport delay (I/O delay).


      This command returns:

                  num: {[0 1]}
                  den: {[1 12]}
             Variable: 's'
              ioDelay: 0
           InputDelay: 0
          OutputDelay: 2.5000
                   Ts: 0
             TimeUnit: 'seconds'
            InputName: {''}
            InputUnit: {''}
           InputGroup: [1x1 struct]
           OutputName: {''}
           OutputUnit: {''}
          OutputGroup: [1x1 struct]
                 Name: ''
                Notes: {}
             UserData: []

      The time delay is stored in the OutputDelay property.

    2. Extract the output delay.

      delay = H.OutputDelay;

Extract PID Gains from Transfer Function

This example shows how to extract PID (proportional-integral-derivative) gains from a transfer function using piddata. You can use the same steps to extract PID gains from a model of any type that represents a PID controller, using piddata or pidstddata.

  1. Create a transfer function that represents a PID controller with a first-order filter on the derivative term.

     Czpk = zpk([-6.6,-0.7],[0,-2],0.2)
  2. Obtain the PID gains and filter constant.

    [Kp,Ki,Kd,Tf] = piddata(Czpk)

    This command returns the proportional gain Kp, integral gain Ki, derivative gain Kd, and derivative filter time constant Tf. Because piddata automatically computes the PID controller parameters, you can extract the PID coefficients without creating a pid model.

 More About

Was this topic helpful?