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.
Command | Result |
---|---|
tfdata | Extract transfer function coefficients |
zpkdata | Extract zero and pole locations and system gain |
ssdata | Extract state-space matrices |
dssdata | Extract descriptor state-space matrices |
frdata | Extract frequency response data from frd
model |
piddata | Extract parallel-form PID data |
pidstddata | Extract standard-form PID data |
get | Access all model property values |
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.
This example shows how to extract transfer function numerator and denominator
coefficients using tfdata
.
Create a first-order plus dead time transfer function model.
s = tf('s'); H = exp(-2.5*s)/(s+12);
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.Numerator{1}; den = H.Denominator{1};
Extract the time delay.
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).
get(H)
Numerator: {[0 1]} Denominator: {[1 12]} Variable: 's' IODelay: 0 InputDelay: 0 OutputDelay: 2.5000 Ts: 0 TimeUnit: 'seconds' InputName: {''} InputUnit: {''} InputGroup: [1×1 struct] OutputName: {''} OutputUnit: {''} OutputGroup: [1×1 struct] Notes: [0×1 string] UserData: [] Name: '' SamplingGrid: [1×1 struct]
The time delay is stored in the OutputDelay
property.
Extract the output delay.
delay = H.OutputDelay;
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
.
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)
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.