Control System Toolbox 8.4
Introduction to the Control System Toolbox - 2 - Accessing Data in a Linear Time-Invariant (LTI) Model Object
In this demo, we'll examine how to access data in an LTI model object using the Control System Toolbox. LTI model objects store data in a single MATLAB variable. This data includes the model coefficients, meaning A,B,C,D matrices of state-space models, as well as other model data, such as the sample time or the input and output names.
We'll look at several ways to access the data:
- The SET / GET functions
- Direct structure referencing
- Data retrieval functions
Contents
Figure 1: Model data in an LTI model object
Accessing Model Data with SET/GET
To modify data, we use the SET function:
set(sys,PropertyName,PropertyValue)
Conversely, we can use the GET function to retrieve model data:
PropertyValue = get(sys,PropertyName)
This illustration shows how to use SET and GET to modify and retrieve the gain value of a zero-pole-gain model.
Figure 2: Accessing model object data with SET/GET.
Accessing Model Data with Direct Structure Referencing
We can also modify and retrieve model data directly by structure referencing:
sys.PropertyName = PropertyValue % equivalent to SET
PropertyValue = sys.PropertyName % equivalent to GET
This illustration shows how this technique parallels the use of the SET and GET functions.
Figure 3: Accessing model object data with 'Direct Structure Referencing.'
Data Retrieval (Quick Access)
We can quickly retrieve model data with the following functions:
[num,den,Ts] = tfdata(sys)
[z,p,k,Ts] = zpkdata(sys)
[a,b,c,d,Ts] = ssdata(sys)
[response,freq,Ts] = frdata(sysfr)
Note that the FRDATA function is specific to FRD models. However, we can use TFDATA, ZPKDATA, and SSDATA with any TF, ZPK, or SS model.
The TFDATA and ZPKDATA functions return some of their data (num,den,z,p) in cell arrays to facilitate data retrieval for MIMO models and model arrays.
For a single SISO model, you can use a second input argument 'v' to specify that these functions return data in vectors rather than cell arrays:
[num,den,Ts] = tfdata(sys,'v')
[z,p,k,Ts] = zpkdata(sys,'v')
The next illustration shows how we can use this technique to quickly retrieve model data
Figure 4: Accessing all model object data with 'Data Retrieval' functions
Additional Information
For more information on feedback control design with the Control System Toolbox, see the Control System Toolbox product information page.
From here you can download a free 30-day trial, read the documentation and user stories, request more information, and get pricing information. See these additional demos of Control System Toolbox functionality:
Store