Mathworks CONTROL SYSTEM TOOLBOX 8 user guide

Control System Too
User’s Guide
lbox™ 8
How to Contact The MathWorks
www.mathworks. comp.soft-sys.matlab Newsgroup www.mathworks.com/contact_TS.html Technical Support
suggest@mathworks.com Product enhancement suggestions
bugs@mathwo doc@mathworks.com Documentation error reports service@mathworks.com Order status, license renewals, passcodes
info@mathwo
com
rks.com
rks.com
Web
Bug reports
Sales, prici
ng, and general information
508-647-7000 (Phone)
508-647-7001 (Fax)
The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098
For contact information about worldwide offices, see the MathWorks Web site.
Control System Toolbox™ User’s Guide
© COPYRIGHT 2001–20 10 by The MathWorks, Inc.
The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or reproduced in any form without prior written consent from The MathW orks, Inc.
FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Documentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern theuse,modification,reproduction,release,performance,display,anddisclosureoftheProgramand Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government’s needs or is inconsistent in any respect with federal procurement law, the government agrees to return the Program and Docu mentation, unused, to The MathWorks, Inc.
Trademarks
MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See
www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand
names may be trademarks or registered trademarks of their respective holders.
Patents
The MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
June 2001 Online only New for Version 5.1 (Release 12.1) July 2002 Online only Revised for Version 5.2 (Release 13) June 2004 Online only Revised for Version 6.0 (Release 14) March 2005 Online only Revised for Version 6.2 (Release 14SP2) September 2005 Online only Revised for Version 6.2.1 (Release 14SP3) March 2006 Online only Revised for Version 7.0 (Release 2006a) September 2006 Online only Revised for Version 7.1 (Release 2006b) March 2007 Online only Revised for Version 8.0 (Release 2007a) September 2007 Online only Revised for Version 8.0.1 (Release 2007b) March 2008 Online only Revised for Version 8.1 (Release 2008a) October 2008 Online only Revised for Version 8.2 (Release 2008b) March 2009 Online only Revised for Version 8.3 (Release 2009a) September 2009 Online only Revised for Version 8.4 (Release 2009b) March 2010 Online only Revised for Version 8.5 (Release 2010a)
LTI Models
1
Representing Linear Time-Invariant (L TI) Systems ... 1-2
Supported Model Types Model Objects Represent Linear Systems Using LTI Models
............................ 1-2
.............. 1-2
................................. 1-3
Contents
Creating Transfer Functions
About Transfer Function Representations Commands for Creating Transfer Functions SISO Transfer Function Models MIMO Transfer Function Models Transfer Functions with Time Delays Pure Gains
Creating State Space M odels
About State-Space Models Commands for Creating State-Space Models Explicit State-Space Models Descriptor (Implicit) State-Space Models State-Space Models with Time Delays
Creating Frequency Response D ata (FRD) Models
About FRD Models Commands for Creating FRD Models Examples of Creating FRD Models Importing Data Into an FRD Model
LTI Properties
What are LTI P rop ertie s ? Generic LTI Properties Model-Specific Properties Setting LTI Properties Accessing Property Values Using get Direct Property Referencing Using Dot Notation Additional Insight into LTI Properties
....................................... 1-13
................................ 1-21
.................................... 1-24
............................. 1-24
............................. 1-28
....................... 1-5
............. 1-5
............ 1-5
...................... 1-6
.................... 1-10
................. 1-11
....................... 1-14
.......................... 1-14
........... 1-14
......................... 1-15
.............. 1-18
................. 1-19
................. 1-22
................... 1-22
................... 1-23
........................... 1-24
........................... 1-26
.................. 1-30
........ 1-31
................ 1-33
.... 1-21
v
Time Delays ....................................... 1-39
Supported Types of Delays Available Properties for Modeling Dela ys Input and Output Delays Specifying I/O Delays in MIMO Models Internal Delays Analyzing Systems With Delays Eliminating Time Del ays: Padé Approximation and Thir an
Filters Sensitivity Analysis Specifying Delays in Discrete-Time Models Discretization Functions That Support Internal Time Delays Functions That Do Not Support Internal Time Delays Inside Time Delay Models
................................... 1-45
........................................ 1-55
.................................... 1-67
.......................... 1-39
.............. 1-40
........................... 1-40
................ 1-43
..................... 1-49
............................... 1-60
............ 1-62
.......... 1-70
... 1-70
.......................... 1-71
Model Conversion
Available Model Formats Explicit Conversion Automatic Conversion Caution About Model Conversions
Simulink Block for LTI Systems
References
........................................ 1-78
................................. 1-73
........................... 1-73
................................ 1-73
.............................. 1-74
.................... 1-75
..................... 1-76
Operations on LTI Models
2
Overview ......................................... 2-2
Precedence and Property Inheritance
Viewing LTI Systems as Matrices
............... 2-3
................... 2-5
vi Contents
Data Retrieval
..................................... 2-6
Extracting and Modifying Subsystems ............... 2-8
What is a Subsystem? Basic Subsystem Concepts Referencing FRD Models Through Frequencies Referencing Channels by Name Resizing LTI Systems
.............................. 2-8
.......................... 2-8
......... 2-11
...................... 2-12
.............................. 2-13
Arithmetic Operations on LTI Models
Supported Arithmetic Operations Addition and Subtraction Multiplication Inversion and Related Operations Transposition Pertransposition
Model Interconnection Functions
Supported Interconnection Functions Concatenation of LTI Models Feedback and Other Interconnection Functions
Converting Between Continuous- and Discrete-Time
Representations
Supported Conversion Functions and Methods Zero-Order H o ld Conversion Method First-Order Hold Conversion Method Impulse-Invariant Mapping Tustin Approximation Zero-Pole Matching E quivalents
Resampling of Discrete-Time Models
Available Commands for Resampling Discrete-Time
Models
Example of Resampling a Discrete-Time Model
.................................... 2-17
..................................... 2-18
.................................. 2-19
................................. 2-24
........................................ 2-37
........................... 2-15
........................ 2-21
......................... 2-28
.............................. 2-32
..................... 2-35
............... 2-15
.................... 2-15
.................... 2-18
................... 2-20
................. 2-20
......... 2-22
.......... 2-24
.................. 2-25
................. 2-27
................ 2-37
......... 2-37
References
........................................ 2-41
vii
Model Analysis Tools
3
General Model Characteristics ...................... 3-2
Model Dynamics
State-Space Realizations
................................... 3-4
........................... 3-7
Arrays of LTI Models
4
Concept of an LTI Array ............................ 4-2
What is an LTI Array? When to Use an LTI Array When to Collect a Set of Models in an LTI Array Restrictions for LTI Models Collected in an Array Where to Find Information on LTI Arrays Visualizing LTI Arrays Higher Dimensional Arrays of LTI Models
Dimensions, Size, and Shape of an LTI Array
I/O and Array Dimensions of LTI Arrays Accessing the Dimensions of an LTI Array Using size and
ndims Using reshape to Rearrange an LTI Array
......................................... 4-10
............................. 4-2
.......................... 4-2
........ 4-3
....... 4-3
............. 4-4
............................. 4-4
............. 4-6
......... 4-8
.............. 4-8
............. 4-12
viii Contents
Building LTI Arrays
Ways to Build LTI Arrays Building LTI Arrays Using for Loops Building LTI Arrays Using the stack Function Building LTI Arrays Using tf, zpk, ss, and frd Generating Random LTI Arrays Using rss
Indexing into LTI Arrays
When to Index into LTI Arrays Organization of Indices
............................... 4-13
........................... 4-13
.................. 4-13
........................... 4-22
...................... 4-22
............................. 4-22
.......... 4-16
.......... 4-18
............. 4-21
Note on Indexing into LTI Arrays of FRD Models ....... 4-23
Accessing Particular Models in an LTI Array Extracting LTI Arrays of Subsystems Reassigning Parts of an LTI Array Deleting Parts of an LTI Array
................. 4-24
................... 4-25
...................... 4-26
........... 4-23
Operations on LTI Arrays
Supported Operations on LTI Arrays Example: Addition of Two LTI Arrays Dimension Requirements Special Cases for Operations on LTI Arrays Other Operations on LTI Arrays
.......................... 4-27
................. 4-27
................. 4-28
........................... 4-29
............ 4-30
..................... 4-32
Customization Preliminaries
5
Terminology ...................................... 5-2
The Property and Preferences Hierarchy
............ 5-3
Setting Toolbox Preferences
6
Toolbox Preferences Editor ......................... 6-2
Overview o f the Toolbox Preferences Editor Opening the Toolbox Preferences Editor
Units Pane
Style Pane
Options Pane
SISO Tool Pane
........................................ 6-4
........................................ 6-5
...................................... 6-6
.................................... 6-7
............ 6-2
............... 6-2
ix
Setting Tool Preferences
7
Introduction ...................................... 7-2
LTI Viewer Preferences Editor
Opening the LTI Viewer Preference Editor Units Pane Style Pane Options Pane Parameters Pane
Graphical Tuning Window Preferences Editor
Opening the Graphical Tuning Window Preferences
Editor Units Pane Time Delays Pane Style Pane Options Pane Line Colors Pane
....................................... 7-4
....................................... 7-4
..................................... 7-5
.................................. 7-6
......................................... 7-8
....................................... 7-9
................................. 7-10
....................................... 7-11
..................................... 7-13
.................................. 7-14
..................... 7-3
............. 7-3
....... 7-8
Customizing Response Plot Properties
8
Introduction ...................................... 8-2
x Contents
Customizing Response Plots Using the Response Plots
Property Editor
Opening the Property Editor Overview o f Response Plots Property Editor Labels Pane Limits Pane Units Pane Style Pane Options Pane Editing Subplots Using the Property Editor
Customizing Response Plots Using Plot Tools
....................................... 8-7
....................................... 8-8
................................. 8-3
........................ 8-3
............ 8-4
...................................... 8-6
...................................... 8-6
..................................... 8-9
............ 8-11
........ 8-12
Properties Yo u Can Customize Using Plot Tools ........ 8-12
Opening and Working with Plot Tools Example of Changing Line Color Using Plot Tools
Customizing Response Plots from the Command
Line
Overview of Customizing Plots from the C ommand Line Obtaining Plot Handles Obtaining Plot Options Handles Examples of Customizing Plots from the Command Line Properties and Values Reference Property Organization Reference
............................................ 8-16
............................ 8-19
................. 8-13
....... 8-13
.. 8-16
..................... 8-20
.. 8-23
..................... 8-27
..................... 8-36
Customizing Plots Inside the SISO Design Tool
Overview of Customizing SISO Design Tool Plots Root Locus Property Editor Open-Loop Bode Property E ditor Open-Loop Nichols Property Editor Prefilter Bode Property Editor
......................... 8-37
..................... 8-41
................... 8-44
....................... 8-46
....... 8-37
....... 8-37
Design Case Studies
9
Yaw Damper for a 747 Jet Transport ................ 9-2
Overview o f this Case Study Creating the Jet Model Computing Open-Loop Eigenvalues Open-Loop Analysis Root Locus Design Washout Filter Design
Hard-Disk Read/W rite Head Controller
Overview o f this Case Study Creating the Read/Write H ead Model Model Discretization Adding a Compensator Gain Adding a Lead Network Design Analysis
............................... 9-5
................................. 9-8
............................... 9-20
................................... 9-26
......................... 9-2
............................. 9-2
................... 9-4
............................. 9-13
.............. 9-19
......................... 9-19
................. 9-19
........................ 9-22
............................ 9-23
xi
LQG Regulation: Rolling Mill Example .............. 9-30
Overview o f this Case Study Process a nd Disturbance Models LQG Design for the x-Axis LQG Design for the y-Axis Cross-Coupling Between Axes MIMO LQG Design
................................ 9-44
......................... 9-30
..................... 9-30
.......................... 9-33
.......................... 9-39
....................... 9-41
10
Kalman Filtering
Overview o f this Case Study Discrete Kalm an Filter Steady-State Design Time-Varying Kalman Filter Time-Varying Design References
.................................. 9-48
......................... 9-48
............................. 9-49
............................... 9-50
........................ 9-56
.............................. 9-56
....................................... 9-60
Reliable Computations
Scaling State-Space Models ......................... 10-2
Why Scaling Is Important When to Scale Your Model Manually Scaling Your Model
How T o Get Accurate Results
........................... 10-2
.......................... 10-2
....................... 10-3
....................... 10-8
xii Contents
11
SISO Design Tool
Overview of the SISO Design Tool ................... 11-2
Opening the SISO Design Tool
Using the SISO Design Task Node
The SISO Design Task Node
...................... 11-3
................... 11-4
........................ 11-4
SISO Design Task Node Menu Bar ................... 11-5
Using the SISO Design Task in the Controls &
Estimation Tools Manager
Architecture Compensator Editor Graphical Tuning Analysis Plots Automated Tuning
...................................... 11-11
............................... 11-18
................................. 11-18
.................................... 11-21
................................ 11-23
........................ 11-11
SISO D e sign Task Graphical Tuning Window
Using the Graphical Tuning Window Menu Bar
Overview of the Graphical Tuning Window Menu Bar File
............................................. 11-43
Edit
............................................. 11-46
View Analysis Tools Window Help
Using the Graphical Tuning Window Toolbar
Using the Right-Click Menus in the Graphical Tuning
Window
Overview of the Right-Click Menus Add Pole/Zero Delete Pole/Zero Edit Compensator Gain Target Show Design Requirements Grid Full View Properties Select Compensator Status Pane
............................................ 11-47
......................................... 11-48
............................................ 11-49
......................................... 11-53
............................................ 11-53
......................................... 11-56
................... 11-56
.................................... 11-57
.................................. 11-60
................................. 11-61
...................................... 11-61
............................................ 11-61
.............................. 11-62
............................................ 11-74
........................................ 11-74
....................................... 11-75
................................ 11-76
...................................... 11-76
........ 11-41
...... 11-43
.... 11-43
........ 11-55
LTI Viewer for SISO Design Task Design
Requirements
................................... 11-77
xiii
12
Overview o f LTI Viewer Design Require ments .......... 11-77
Available Design Requirements in the LTI Viewer Example: Time Domain Requirement
................. 11-78
...... 11-77
LTI Viewer
Basic LTI Viewer Tasks ............................ 12-2
UsingtheRight-ClickMenuintheLTIViewer
Overview o f the Right-Click Menu Setting Characteristics of Response Plots Adding Design Requirements
Importing, Exporting, and Deleting Models in the LTI
Viewer
Importing Models Exporting M odels Deleting Models
Selecting Response Types
Methods for Selecting Response Types Right Click Menu: Plot Type Plot Configurations Window Line Styles Editor
Analyzing MIMO Models
Overview of Analyzing MIMO Models Array Selector I/O Grouping for MIMO Models Selecting I/O Pairs
......................................... 12-12
................................. 12-12
................................. 12-13
................................... 12-14
.......................... 12-16
................................. 12-18
........................... 12-20
.................................... 12-21
................................ 12-24
.................... 12-4
.............. 12-4
........................ 12-9
................ 12-16
........................ 12-16
......................... 12-16
................. 12-20
...................... 12-23
....... 12-4
xiv Contents
Customizing the LTI Viewer
Overview o f Customizing the LTI Viewer LTI Viewer Preferences Editor
........................ 12-25
....................... 12-25
.............. 12-25
Index
xv
xvi Contents

LTI Models

“Representing Linear Time-Invariant (LTI) System s” on page 1-2
“Creating Transfer Functions” on page 1-5
“Creating State Space Models” on page 1-14
“Creating Frequency Response Data (FRD) Models” on page 1-21
“LTI Properties” on page 1-24
“Time Delays” on page 1-39
“Model Conversion” on page 1-73
1
“Simulink Block for LTI Systems” on page 1-76
“References” on page 1-78
1 LT I Models

Representing Linear Time-Invariant (LTI) Systems

In this section...
“Supported Model Types” on page 1-2 “Model Objects Represent Linear Systems” on page 1-2 “Using LTI Models” on page 1-3

Supported Model Types

You can represent continuous- and discrete-time systems in Control System Toolbox™ as:
Transfer functions
State-space models
Frequency responsedata(FRD)models
1-2
Your system can be single-input/single-output (SISO) or multiple-input/multiple-output (MIMO).

Model Objects Represent Linear Systems

The Control System Toolbox software provides customized data structures, known as LTI model objects , for each ty pe of model: . These LTI model objects encapsulate the model data. They allow you to manipulate LTI systems as single entities rather than collections of data vectors or matrices.
Depending on the type of model you use, the data for your model can include:
One or more numerator/denominator pairs for transfer functions
Matrices for state-space models
Zeros and poles for zero-pole-gain models
Frequency and response vectors for FRD models
tf, zpk, ss,andfrd
Representing Linear Time-Invariant (LTI) Systems
Note AllLTImodelobjectsareMATLAB®objects. See “ MA TLAB Classes” in the MATLAB documentation if you are not familiar with objects and object syntax.
LTI Properties and Methods
LTI m odel objects include predefined fields, known as object properties,which store model data such as model parameters, sampling time, delays, and input and output channel names (see “LTI Properties” on page 1-24).
The ope rations you can perform on a particular object are the object methods.
For information about creating LTI model objects, see:
“Creating Transfer Functions” on page 1-5
“Creating State Space Models” on page 1-14
“Creating Frequency Response Data (FRD) Models” on page 1-21
To learn more about allowed operations on LTI model objects, see Chapter 2, “Operations on LTI Models”.

Using LTI Models

After you represent your LTI model, you manipulate the model using arithmetic and model interconnection operations (see Chapter 2, “Operations on LTI Models”). You also can analyze the model response using commands such as
Analysis of
You can design compensators for systems specified as models. Available compensator design techniques include root locus analysis, pole placement, LQG optimal control, and frequency domain loop-shaping.
For
bode and step (see Chapter 3, “Model Analysis Tools”).
frd m odels is restricted to frequency-domain methods.
tf, zpk, ss,andfrd
frd models, you can:
1-3
1 LT I Models
Use frequency-domain design techniques to design a controller for the
frd model.
Identify a design a controller for the identified model.
tf, zpk,orss model usi ng “System Identification Toolbox™” and
1-4

Creating Transfer Functions

In this section...
“About Transfer Function Representations” on page 1-5 “Commands for Creating Transfer Functions” on page 1-5 “SISO Transfer Function Models” on page 1-6 “MIMO Transfer Function Models” on page 1-10 “Transfer Functions with Time Delays” on page 1-11 “Pure Gains” on page 1-13

About Transfer Function Representations

With Control System Toolbox software, you can represent linear s ystems as transfer functions in polynomial or factorized (zero-pole-gain) form. All model objects represent transfer functions in polynomial form. The zpk model objects represent transfer functions in factorized form.
Creating Transfer Functions
tf
Control System Toolbox software supports transfer functions that are continuous-time or discrete-time, and SISO or MIMO. You can also have time delays in your transfer function representation.

Commands for Creating Transfer F unctions

Use the commands described in the followingtabletocreatetransfer functions.
1-5
1 LT I Models
Command
tf
zpk
filt
For examples of using these commands, see:
“SISO Transfer Function Models” on page 1-6
“MIMO Transfer Function Models” on page 1-10
“Transfer Functions with Time Delays” on page 1-11
“Pure Gains” on page 1-13
Description
Create tf objects representing transfer functions in polynomial form.
Create zpk objects representing transfer functions in zero-pole-gain (factorized) form.
Create tf objects representing discrete-time transfer functions using digital signal processing (DSP) convention.

SISO Transfer Function Models

1-6
“Continuous-Time SISO Transfer Functions in Polynomial Form” on page 1-6
“Continuous-Time SISO Transfer Functions in Zero-Pole-Gain Form” on page 1-7
“Discrete-Time SISO Transfer Functions” on page 1-8
“Discrete Transfer Functions in DSP Form” on page 1-9
Continuous-Time SISO Transfer Functions in Polynomial Form
A continuous-time SISO transfer function in polynomial form is given by:
Ns
=
()
Ds
()
,
Gs
()
Creating Transfer Functions
where s is the Laplace variable, N(s) is the numerator polynomial, and D(s)is the denominator polynomial.
Create a SISO transfer function model in polynomial form using:
G = tf(num,den)
where num and den are row vectors of coefficients of the polynomials N(s) and D(s), respectively. These row vectors are ordered in descending powers of s.
G is a tf model object.
For example, create the transfer function G(s)=s/(s
G = tf([1 0],[1 2 1]);
2
+2s +1),using:
Alternatively, you can specify the same tf model as a rational expression in the Laplace variable s:
s = tf('s'); % Define the Laplace variable s G = s/(s^2 + 2*s + 1); % Spec ify rational expression in s
After you define the variable s, you can create multiple tf models by specifying additional rational expressions of
For more examples, see the
tf reference page.
s.
Continuous-Time SISO Transfer Functions in Zero-Pole-Gain Form
A continuous-time SISO transfer function in factorized (zero-pole-gain) form is given by:
sz sz
Gs k
=
()
()
sp sp
()
()
1
1
m
()
n
,
where:
k is a real- or complex-valued scalar gain.
z
,..., zmare the real or complex conjugate pairs of zeros of the transfer
1
function G(s)—rootsofthenumeratorpolynomialN(s).
1-7
1 LT I Models
p1,..., pnare the real or complex conjugate pairs of poles of the transfer
function G(s) — roots of the denominator polynom ial D(s).
Create transfer functions in factorized (
G = zpk(z, p, k)
where z, p,andk are row vectors of zeroes z1,..., zm, poles p1,..., pn,andgaink respectively.
For example, the transfer function G(s)=s/(s give by:
Gs
()
This transfer function has a zero at s =0,twopolesats = –1, and a gain of 1.
Create a
G = zpk([0],[-1 -1],[1]);
Alternatively, you can specify the same zpk model as a rational expression in the Laplace variable s:
s = zpk('s'); % Define the Laplace variable s G = s/(s+1)^2; % Specify the rational expression
s
=
s
()
zpk m o del of this transfer function using:
.
2
1
+
zpk)formusing:
2
+2s +1)infactorizedformis
1-8
After you define the variable s, you can create multiple zpk models by specifying additional rational expressions of
For more examples, see the
zpk reference page.
s.
Discrete-Time SISO Transfer Functions
In discrete time, a transfer function can be expressed as a ratio of polynomials in the discrete-time variable z:
Nz
=
()
Dz
()
Gz
()
Creating Transfer Functions
Create a discrete-time S ISO transfer function using the tf or zpk commands with an argument that specifies the sampling time.
For example, create the discrete-time transfer function G(z)=z/(z with a sampling time of 0.1 s, using:
G = tf([1 0],[1 -2 -6],0.1)
G
is a tf model object with a sampling time of 0.1 s.
To create a discrete
Gz
=
()
zz
+
()
use the following command:
G = zpk([0],[-2, 3],[1],0.1);
Alternatively, you can specify a discrete-time tf or zpk model as a rational expression in z by defining the variable z with the d esired sampling time. For example:
z = tf('z',0.1); % Define the variable z and sampling time G = z/(z^2 - 2*z - 6); % Spec ify the rational expression
For m ore examples of creating discrete-time transfer functions in polynomial and factorized form, see the
zpk model with a 0.1-second sampling time:
z
23
,
()
tf and zpk reference pages.
2
–2z –6)
Discrete Transfer Functions in DSP Form
The control and digital signal processing (DSP) domains use different conventions to specify discrete-time transfer functions.
Typically, control engineers express transfer functions using the z variable, and order the numerator and denominator terms in descending powers of z. For example:
2
4
z
Gz
()
=
+
2
25
zz
++
1-9
1 LT I Models
The syntax for creating transfer functions using tf assumes the control engineering convention. However, DSP engineers often write this transfer function as:
1
Gz
=
()
12 5
++
14
2
+
z
−−
12
zz
where the numerator and denominator are expressions in z–1,orderedin ascending powers of z
You can use
filt to create a transfer function using the DSP convention. For
example, create the transfer function G
Gdsp = filt([1 0 4], [1 2 5], 0.1); % 0.1 s sampling time
is a discrete-time tf model object. For additional examples, see the
Gdsp filt reference page.
Alternatively, you can use setting the
G = tf([1 0 4], [1 2 5], 0.1 , 'Variable', 'z^-1');
'Variable' property to 'z^-1':
–1
.
–1
'(z
)using:
tf to create transfer functions in DSP form by
For mo re information about setting model properties, see “LTI Properties” on page 1-24 and the
tf reference page.

MIMO Transfer Function Models

A MIMO transfer function is a matrix of SISO transfer functions that define the response for each input-output channel of a MIMO system.
Create MIMO transfer function models using one of the following approaches:
1-10
Concatenate SISO
Use
tf or zpk commands with cell array arguments.
tf orzpk models.
For example, to create the two-input, one-output MIMO transfer function
Creating Transfer Functions
1
s
Gs
()
⎡ ⎢
s
=
s
2
ss
++
⎤ ⎥
1
+
2
+
⎥ ⎥
45
you can specify the SISO transfer functions for each channel and concatenate these transfer functions:
g11 = tf([1 -1],[1 1]); % first input to outpu t g21 = tf([1 2],[1 4 5]); % second input to output G = [g11; g21];
See “Model Interconnection Functions” on page 2-20 for more information about concatenating linear systems.
You can also define MIMO transfer functions directly using MIMO transfer matrix G(s), the cell array entries
N{i,j} and D{i,j} are
row-vector representations of the numerator and denominator of G
tf. For a general
(s), the
ij
ijth entry of the transfer matrix G(s).
For example, to create the previous two-input, one-output MIMO system G(s):
N = {[1 -1];[1 2]}; D = {[1 1];[1 4 5]}; H = tf(N,D);
You can also use zpk to create MIMO zero-pole-gain transfer functions. To specify MIMO transfer functions in DSP form as expressions in z For more examples of creating MIMO transfer functions, see the
filt reference pages.
–1
,usefilt.
tf, zpk,and

Transfer Functions with T ime Delays

You can represent transfer functions with time delays by specifying the delay on each input-output channel of the system.
To create a transfer function with a time delay, specify the of the
tf or zpk model object. For SISO transfer functions, set 'ioDelay' to a
scalar value representing the time delay in seconds. For example:
'ioDelay' property
1-11
1 LT I Models
G = tf([1 1], [1 5 3]); G.ioDelay = 2;
For MIM O transfer functions, specify the 'ioDelay' property as an array of time delays corresponding to each input-output channel. For example:
s = tf('s'); sys = [2/s (s+1)/(s+10); 10 (s-1)/(s+5)]; tau = [0.1 0.3; 0 0.2]; % C reat e I/O delay matrix. sys.ioDelay = tau; % Add I/O delays to sys.
The resulting transfer function is:
Transfer function from in put 1 to output...
2
#1: exp(-0.1*s) * -
s
#2: 10
1-12
Transfer function from inp ut 2 to output...
s+1
#1: exp(-0.3*s) * ------
s+10
s-1
#2: exp(-0.2*s) * -----
s+5
For more information about setting model properties, see “LTI Properties” on page 1-24 and the
tf and zpk reference p ages .
Alternatively, you can define the variable s or z and enter the time delay as an exponential term in an algebraic expression in s or z. For example:
s = tf('s'); G = exp(-2*s)*(s+1)/(s^2 + 5*s + 3);
For more information about working with models that have time delays, see “Time Delays” on page 1-39.
Creating Transfer Functions

Pure Gains

You can use tf to specify simple gains or gain matrices as tf model objects. For example, create a two-input, two-output gain matrix using:
G = tf([1 0;2 1]);
1-13
1 LT I Models

Creating State Space Models

In this section...
“About State-Space Models” on page 1-14 “Commands for Creating State-Space Models” on page 1-14 “Explicit State-Space Models” on page 1-15 “Descriptor (Implicit) State-Space Models” on page 1-18 “State-Space Models with Time Delays” on page 1-19

About State-Space Models

State-space models rely on linear differential equations or difference equations to describe system dynamics. State-space models can result from:
Linearizing a set of ordinary differential equations that represent a physical model of the system.
1-14
State-space model identification using “System Identification Toolbox”.
State-space realization of the system transfer f unction. (See “Model
Conversion” on page 1-73 for more information.)
Control System Toolbox software supports state-space models in continuous-time or discrete-time, SISO or MIMO, and these m odels can include time delays. You can represent state-space m odels in either explicit or descriptor (implicit) form.

Commands for Creating State-Space Models

Use the com mands described in the following table to create s tate-space models.
cription
Command
ss
dss
Des
Create explicit state-space model. Create descriptor (implicit) state-space
model.
Creating State Space Models
Command
rss
drss
For examples of creating state-space models, see:
“Explicit State-Space Models” on page 1-15
“Descriptor (Implicit) State-Space Models” on page 1-18
“State-Space Models with Time Delays” on page 1-19
Description
Generate random continuous state-space model.
Generate random discrete state-space model.

Explicit State-Space Models

“Explicit State-Space Models in Continuous Time” on page 1-15
“Explicit State-Space Models in D iscrete Time” on page 1-17
Explicit State-Space Models in Continuous Time
Continuous-time explicit state-space models have the following form:
dx
Ax Bu
=+
dt
yCxDu
=+
where x is the state vector. u and y are the input and output vectors. A, B, C, and D are the state-space matrices.
Create explicit state-space models using:
sys = ss(A,B,C,D);
The output is an ss object sys that stores the state-space matrices A, B, C, and D.
For example, consider the following simple model of an electric motor:
1-15
1 LT I Models
2
d
dt
where θ is the angular displacement of the rotor and I is the driving current. The following state-space equations describe the relationship between the input u = I and the angular velocity y = dθ/dt:
dx
=+
dt
yCxDu
=+
where
x
d

253
++=,
2
dt
Ax Bu
=
d
dt
I
1-16
and the state-space matrices are:
01
ABCD=
−−
To create this model in Control S ystem Toolbox software, use:
sys = ss([0 1;-5 -2],[0;3],[0 1],0, ...
The resulting ss model displays as:
a=
displacement 0 1 velocity -5 -2
b=
displacement 0
⎤ ⎥
52
'StateName', {'displacement', 'velocity'}, ... 'InputName', 'I', 'OutputName', 'velocity')
0
=
3
displacement velocity
I
01 0
=
[]=[]
Creating State Space Models
velocity 3
c=
displacement velocity
velocity 0 1
d=
I
velocity 0
Continuous-time model.
The display of state-space models includes state names, input names, and output names that you can optionally specify. When you leave the names unspecified, the display includes the default names (for example,
y1). See “LTI Properties” on page 1-24 for more information on how to specify
state, input, or output names.
x1, u1,and
Explicit State-Space Models in Discrete Time
A discrete-time explicit state-space model takes the following form:
xn Axn Bun
+
1
[]=[]+[]
yn Cxn Dun
=
[]
where the vectors x[n], u[n], and y[n] are the state, input, and output vectors for the nth sample.
Create a discrete-time explici t state-space model using the an argument that specifies the sampling time.
For example, to create a state-space model with a sampling time of 0.25 s and the following state-space matrices:
01
ABCD=
−−
use:
[]+[]
⎤ ⎥
52
ss command with
0
=
3
=
01 0
⎥ ⎦
[]=[]
1-17
1 LT I Models
sys = ss([0 1;-5 -2],[0;3],[0 1],0, 0.25);

Descriptor (Implicit) State-Space Models

A descriptor state-space model is a generalized form of state-space model. In continuous time, a descriptor state-space model takes the follow ing form:
Ex Ax Bu
=+
yCxDu
=+
where x is the state vector and u and y are the input and output vectors. A, B, C, D,andE are the state-space matrices.
For example, conside r the following simp le dynamic model of a rotating body (no restoring force):
d
J
FT
+=
dt
y
=
1-18
where J is the inertia matrix, the input u = T is the driving torque, and F is the force matrix. The output y = ω is the vector of angular velocities of the rotating body.
To represent this system as an explicit state-space model, you can multiply the first equation by J matrix J is not conditioned well for inversion, however, computing J be impractical or impossible. In that case, you can specify this system as a descriptor model with A =–F, B =1,C =1,D =0,andE = J.
Create descriptor systems using:
sys = dss(A,B,C,D,E);
is a continuous-time ss object with matrices A, B, C, D,andE.
sys
For example, to create the descriptor state-space model of the rotating body, use:
sys = dss(-F,eye(3),eye(3),0,J);
–1
, the inverse of the inertia matrix. If the inertia
–1
can
Creating State Space Models
This representation assumes three axes of rotation.
To create a discrete-time descriptor state-space model, use:
sysd = dss(A,B,C,D,E,Ts);
where Ts specifies the sampling time.
You can assign names to the states, inputs, and outputs of a descriptor state-space model. See “LTI Properties” on page 1-24 for more information.

State-Space M odels with Time Delays

Both explicit and descriptor state-space models can include three types of time delays, stored as the following properties of the
InputDelay — D elays at model inputs. OuputDelay — Delays at model outputs.
ss object:
InternalDelay — Internal delays resulting from combining models with
delays or closing feedback loops.
To create a state-space model with a time delay, set the value of the corresponding delay property of the
ss object. For example, create a
state-space model with a 1.2-s time delay at the input:
sys = ss([0 1;-5 -2],[0;3],[0 1],0,'InputDelay', 1.2) ;
The value of either the 'InputDelay' or 'OutputDelay' property is a vector whose length equals the number of inputs or outputs in the model.
You can interconnect state-space models or include a state-space model in a feedback loop. When you do so, the Control System Toolbox software can convert input or output delays to internal delays. Because
ss objects can track
such internal delays, state-space repr ese ntation is best suited for modeling and analyzing delay effects in control systems. See “Internal Delays” on page 1-45 for more information.
1-19
1 LT I Models
For more information about creating and working with state-space models with time delays generally, see “Time Delays” on page 1-39.
1-20

Creating Frequency Response Data (FRD) Models

Creating Frequency Response Data (FRD) Models
In this section...
“About FRD Models” on page 1-21 “Commands for Creating FRD Models” on page 1-22 “Examples of Creatin g FRD Models” on page 1-22 “Importing D ata Into an FRD Model” on page 1-23

About FRD Models

In the Control System Toolbox software, you can use frd models to store, manipulate, and analyze frequency response data. An vector of frequency points with the corresponding complex frequency response datayouobtaineitherthroughsimulations or experimentally.
For example, suppose you measure frequency response data for the SISO system you want to model. You can mea sure such data by driving the system withasinewaveatasetoffrequenciesω
, ω2, ,.. .,ωn,asillustrated:
1
frd model stores a
teady state, the measured response y
At s
quency ω
fre
yt a t b i n
()
ii
e measurement yields the complex frequency respo ns e G at each input
Th
equency:
fr
takes the following form:
i
=+
()
=sin , , , .
1
(t) to the driving signal at each
i
1-21
1 LT I Models
Gaei n
()
i
You can do most frequency-domain analysis tasks on frd models, but you cannot perform time-domain simulations with them. For information on frequency response analysis of linear syste ms, see Chapter 8 of [1].
jb
==,,,.1

Commands for Creating FRD Models

Use the following commands to create FRD models.
Command
frd
frestimate
Description
Create frd objects from frequency response data.
Create frd objects by estimating the frequency response of a Simulink model. Requires Simulink®Control Design™ — see “Frequency Response Estimation of Simulink Models” in the Simulink Control Design User’s Guide for more information.
®
1-22

Examples of Creating FRD Models

Create continuous-time frd models from frequency respo ns e data using the
frd command:
sys = frd(response,frequencies,unit);
where, for SISO frd models:
frequencies is a real vector of length Nf. response is a vector of length Nf of complex frequency response values for
each value in
unit is an optional string for the unit of frequency: either 'rad/s'(default)
or
'Hz'
frequencies.
Creating Frequency Response Data (FRD) Models
To create a continuous-time MIMO frd model, use the same syntax and inputs. However, change
responseto be a multidimensional array whose
dimensions depend upon the number of inputs and outputs and the length o f
frequencies. For example, to represent a two-input, one-output system w ith
50 frequency response data points,
response isa1x2x50array.
To create a discrete-time SISO or MIMO
sysd = frd(response,frequencies,unit,Ts); % Ts = sampling time in seconds
frd model, specify the sampling time:

Importing Data Into an FRD Model

You can create a frd model using measured data from your plant by importing the data from a data file into the MATLAB workspace. For example, the file
LTIexamples.mat contains a frequency vector freq, and a corresponding
complex frequency response data vector data and construct a
load LTIexamples sys = frd(respG, freq);
frd model, type
For m ore information about creating and manipulating frd models, see the
frd reference p age.
respG. To load this frequency-domain
1-23
1 LT I Models

LTI Properties

In this section...
“What are LTI Properties?” on page 1-24 “Generic LTI Properties” on page 1-24 “Model-Specific Properties” on page 1-26 “Setting LTI Properties” on page 1-28 “Accessing Property Values Using get” on page 1-30 “Direct Pro pe rty Referencing Using Dot Notation” on page 1-31 “Additional Insight into LTI Properties” on page 1-33

What are LTI Properties?

The previous section shows how to create LTI objects that encapsulate the model data and sample time. You also have the option to attribute additional information, such as the input names or notes on the model history, to LTI objects. This section gives a complete overview of the LTI properties,i.e.,the various pieces of information that can be attached to the TF, ZPK, SS, and FRD objects. Type
helpltiprops for online help on av ailable LTI properties.
1-24
From a data structure standpoint, the LTI properties are the various fields in the TF, ZPK, SS, and FRD objects. These fields have names (the property
names) and are assigned values (the property values). We distinguish between generic properties, common to all four types of LTI objects, and model-specific properties that pertain only to one particular type of model.

Generic LTI Properties

The generic properties are those shared by all four types of LTI models (TF, ZPK, SS, and FRD objects). They are listed in the table below.

LTI Properties Common to All LTI Objects

Property Name Description Data Type
InputDelay
InputGroup
InputName
Notes
OutputDelay
OutputGroup
OutputName
Ts
Userdata
Input delay(s) Input channel groups Input channel names Notes on the model history Output delay(s) Output channel groups Structure Output channel names Cell vector of strings Sample time Scalar Additional data Arbitrary
Vector Structure Cell vector of strings Text Vector
ThesampletimepropertyTs keepstrackofthesampletime(inseconds) of discrete-time systems. By convention, systems, and
Ts is always a scalar, even for MIMO systems.
Ts is -1 for discrete-time systems with unspecified sample time.
Ts is 0 (zero) for continuous-time
LTI Properties
The
InputDelay, OutputDelay, ioDelay and InternalDelay properties
allow you to specify time delays in the input or output channels, or for each input/output pair. Their default value is zero (no delay). See “Time Delays” on page 1-39 for details on modeling delays.
The
InputName and OutputName properties enable you to give names to the
individual input and output channels. The value of each of these properties is a cell vector of strings with as many cells as inputs or outputs. For example, the
OutputName property is set to
{ 'temperature' ; 'pressu re' }
for a system with two outputs labeled tem perature and pressure.The default value is a cell of empty strings.
Using the
InputGroup and OutputGroup properties of LTI objects, you can
create different groups of input or output channels, and assign names to the
1-25
1 LT I Models
groups. For example, you may want to designate the first four inputs of a five-input model as and Output Groups” on page 1-36 for more information.
controls, and the last input as noise. See “Input Groups
Finally, the model. The with your model, while the user-supplied data. They are both empty by default.
For more detailed information on how to use LTI properties, see “Additional Insight into LTI Properties” on page 1-33.
Notes and Userdata are available to store additional information on
Notes property is dedicated to any text you want to supply
Userdata property can accommodate arbitrary

Model-Specific Properties

The remaining LTI properties are specific to one of the four model types (TF, ZPK, SS, or FRD). For single LTI models, these are summarized in the following four tables. The property values differ for LTI arrays. See more information on these values.
TF-Specific Properties
Property Name Description Data Type
den
num
ioDelay
Variable
Denominator(s) Real cell array of row
vectors
Numerator(s) Real cell array of row
vectors I/O delay(s) Transfer function variable String 's', 'p', 'z', 'q',
Matrix
or
'z^-1'
set for
1-26
ZPK-Specific Properties
Property Name Description Data Type
z
p
k
Variable
ioDelay
Zeros Poles Gains Transfer function
variable I/O delay(s)
Cell array of column vectors Cell array of column vectors Two-dimensional real matrix String 's', 'p', 'z', 'q',or
'z^-1'
Matrix
SS-Specific Properties
Property Name De sc ription Data Type
a
b
c
d
e
State matrix A Input-to-state matrix B 2-D real matrix State-to-output matrix C Feedthrough m atrix D 2-D real matrix Descriptor E matrix 2-D real matrix
2-D real matrix
2-D real matrix
LTI Properties
InternalDelay
StateName
Scaled
Internal delay(s)
Vector State names Cell vector of strings When false, numerical
0 for false, 1 for true
algorithms rescale the state vector to improve accuracy.
When true, the model is marked as already scaled and no rescaling occurs.
1-27
1 LT I Models
FRD-Specific Properties
Property Name Description Data Type
Frequency
ResponseData
Units
Most of these properties are dedicated to storing the model data. Note that the E matrix is set to astorage-efficientshorthand for the true value E = I.
The
Variable property is only an attribute of TF and ZPK objects. This
property defines the frequency variable of transfer functions. The default values are
's' (Laplace variable s) in continuous time and 'z' (Z-transform
variable z) in discrete time. Alternative choices include
'q' (equivalent to z), and 'z^-1' for the reciprocal of the z variable. The
influence of the variable choice is mostly limited to the display of TF or ZPK models. One exception is the spe c if ica t ion of discrete-time transfer functions with
tf (see tf for details).
Frequency data points Real-valued vector Frequency response
Complex-valued multidimensional array
Units for frequency String ’rad/s’ or ’Hz’
[] (the empty matrix) for standard state-space models,
'p' (equivalent to s),
1-28
Note that is set to
Finally, the
OutputName properties and keeps track of the state names in state-space
tf produces the same result as filt when the Variable property
'z^-1'.
StateName property is analogous to the InputName and
models.

Setting LTI Properties

There are three ways to specify LTI property values:
You can set properties when creating LTI models with
You can set or modify the properties of an existing LTI model with
You can also set pro pe rty values using structure-like assignments.
This section discusses the first two options. See “Direct Property Referencing Using Dot Notation” on page 1-31 for details on the third option.
tf, zpk, ss,orfrd.
set.
LTI Properties
The function set for LTI objects follows the same syntax as its Handle Graphics counterpart. Specifically, each property is updated by a pair of arguments
PropertyName,PropertyValue
where
PropertyName is a string specifying the property name. You can type
the property name without regard for the case (upper or lower) of the letters in the name. Actually, you need only type any abbreviation of the property name that unique ly identifies the property. For example,
'user'
is sufficient to refer to the Userdata property.
PropertyValue is the value to assign to the property (see set for d etails on
admissible property values).
As an illu stration, consider the following simple SISO model for a heating system with an input delay of 0.3 seconds, an input called "energy," and an output called "temperature."
ASimpl
You can delay corre when y
For e and t to sy
e Heater Model
use a TF object to represent this delay system, and specify the time
, the input and output names, and the model history by setting the
sponding LTI properties
ou create the LTI model with
. You can eithe r set these properties directly
tf,orbyusingtheset command.
xample, you can specify the delay directly when you create the model, hen use the
s
.
sys = tf(1,[1 1],'Inputde lay',0.3); set(sys,'inputname','energy','outputname','temperature',... 'notes','A simple heater m odel')
set command to assign InputName, OutputName,andNotes
1-29
1 LT I Models
Finally, you can also use the set command to obtain a listing of all setable properties for a given LTI model type, along with valid values for these properties. For the transfer function
set(sys)
sys created above
produces
num: Ny-by-Nu cell array of row vectors (Nu = no. of inputs) den: Ny-by-Nu cell array of row vectors (Ny = no. of outputs) ioDelay: Ny-by-Nu array of delays for each I/O pair Variable: [ 's' | 'p' | 'z' | 'z^-1' | 'q' ] Ts: Scalar (sample time in seconds) InputDelay: Nu-by-1 vector OutputDelay: Ny-by-1 vector InputName: Nu-by-1 cell ar ray of strings OutputName: Ny-by-1 cell a rray of strings InputGroup: structure with one field per channel group. OutputGroup: structure with one field per channel group. Name: String Notes: Text UserData: Arbitrary
1-30

Accessing Property Values Using get

You access the property values of an LTI model sys with get. The syntax is
PropertyValue = get(sys,PropertyName)
where the string PropertyName is either the full property name, or any abbreviation with enough characters to identify the property uniquely. For example, typing
h = tf(100,[1 5 100],'inputname','vol tage',...
'outputn','current',... 'notes','A simple circuit')
get(h,'notes')
produces
ans =
LTI Properties
'A simple circuit'
To display all of the properties of an LTI model sys (and their values), use the syntax
get(sys).Inthisexample,
get(h)
produces
num: {[0 0 100]} den: {[1 5 100]}
ioDelay: 0
Variable: 's'
Ts: 0
InputDelay: 0
OutputDelay: 0
InputName: {'voltage'} OutputName: {'current'} InputGroup: [1x1 struct]
OutputGroup: [1x1 struct]
Name: ''
Notes: {'A simple circuit'}
UserData: []
Notice that default (output) values have been assigned to any LTI properties in this l ist that you have not specif ied.
Finally, you can also access p rop erty values using direct structure-like referencing. This topic is explained in “Direct Property Referencing Using Dot Notation” on page 1-31

Direct Property Referencing Using Dot Notation

An alternative way to query/modify property values is by structure-like referencing. Recall that LTI objects are basic MATLAB structures except for the additional flag that marks them as TF, ZPK, SS, or FRD objects (see “Model Objects Represent Linear Systems” on page 1-2). The field names for LTI objects are the property names, so you can retrieve or modify property values with the structure-like syntax.
1-31
1 LT I Models
PropertyValue = sys.PropertyName % gets property value
PropertyName = PropertyValue % set s property value
sys.
These commands are respectively equivalent to
PropertyValue = get(sys,'PropertyName') set(sys,'
PropertyName',PropertyValue)
For example, type
sys = ss(1,2,3,4,'InputName','u'); sys.a
and you get the value of the property "a" for the state-space model sys.
ans =
1
Similarly,
1-32
sys.a = -1;
resets the state transition matrix for sys to -1.
Unlike standard MATLAB structures, you do not need to type the entire field name or use upper-case characters. You only need to type the minimum number of characters sufficient to identify the property name uniquely. Thus either of the commands
sys.InputName sys.inputn
produces
ans =
'u'
Any valid syntax for structures extends to LTI objects. For example, given the TF model
LTI Properties
h = tf(1,[1,0],'variable','p');
you can reset the numerator to by typing
h.num{1} = [1 2];
or equivalently, with
h.num{1}(2) = 2;

Additional Insight into LTI Properties

By reading this section, y ou can learn more about using the Ts, InputName,
OutputName, InputGroup,andOutputGroup LTI properties through a set of
examples. For basic information on Properties” on page 1-24. For detailed information on the use of
OutputDelay, ioDelay,andI nternalDelay, see “Time Delays” on page 1-39.
Sample Time
ThesampletimepropertyTs is used to specify the sampling period (in seconds)foreitherdiscrete-timeordiscretized continuous-time LTI models. Suppose you w ant to specify
Notes and Userdata, see “Generic LTI
InputDelay,
as a discrete-time transfer function model with a sampling period of 0.5 seconds. To do this, type
h = tf([1 0],[2 1 1],0.5);
This sets the Ts property to the value 0.5, as is confirmed by
h.Ts
ans =
0.5000
Forcontinuous-timemodels,thesampletimepropertyTs is 0 by convention. For example, type
1-33
1 LT I Models
h = tf(1,[1 0]); get(h,'Ts')
ans =
0
To leave the sample time of a discrete-time LTI model unspecified, set Ts to
. For example,
h = tf(1,[1 -1],-1)
produces
Transfer function:
1
----­z-1
Sampling time: unspecified
1-34
ThesameresultisobtainedbyusingtheVariable property.
h = tf(1,[1 -1],'var','z' )
In operations that combine several discrete-time models, all specified sample times must be identical, and the resulting discrete-time model inherits this common sample time. The sample time of the resultant model is unspecified if all operands have unspecified sample times. With this inheritance rule for
Ts,
the following two models a re equivalent.
tf(0.1,[1 -1],0.1) + tf(1,[1 0.5],-1)
and
tf(0.1,[1 -1],0.1) + tf(1,[1 0.5],0.1)
Note that
tf(0.1,[1 -1],0.1) + tf(1,[1 0.5],0.5)
returns an error message.
LTI Properties
??? Error using ==> lti/p lus In SYS1+SYS2, both models must have the same sample time.
Caution Resetting the sample time of a continuous-time LTI model sys from zero to a nonzero value does not discretize the o riginal model sys.The command
set(sys,'Ts',0.1)
only affects the Ts property and d
c2d and d2c to perform continuous
oes not alter the remaining model data. Use
-to-discrete and discrete-to-continuous
conversions. For example, use
sysd = c2d(sys,0.1)
to discretize a continuous system sys at a 10Hz sampling rate. U se d2d to changethesampletimeofadiscrete-time system and resample it.
Input Names and Output Names
You can use the InputName and Output Name properties (in short, I/O names) to assign names to any or all of the input and output channels in your LTI model.
For example, you can create a SISO model with input
velocity, and transfer function by typing
h = tf(1,[1 10]); set(h,'inputname','thrust','outputname','velocity',...
'variable','p')
Equivalently, you can set these properties directly by typing
h = tf(1,[1 10],'inputnam e','thrust',...
'outputname','velocity',... 'variable','p')
thrust, output
This produces
Transfer function from in put "thrust" to output "velocity":
1
1-35
1 LT I Models
-----­p+10
Note how the display reflects the input and output names a nd the variable selection.
In the MIMO case, use cell vectors of strings to specify input or output channel names. For example, type
num = {3 , [1 2]}; den = {[1 10] , [1 0]}; H = tf(num,den); % H(s) has one output and two inputs
set(H,'inputname',{'temperature' ; 'pressure'})
The s pecified input names appear in the display of H.
Transfer function from in put "temperature" to output :
3
-----­s+10
1-36
Transfer function from inp ut "pressure" to output: s+2
----­s
To leave certain names undefined, use the empty string '' as in
H = tf(num,den,'inputname',{ 'temperature' ; '' })
InputGroupsandOutputGroups
In many applications, you may want to create several (distinct or intersecting) groups of input or output channels and name these groups. For example, you may want to label one set of input channels as as
controls.
To see how input and output groups (I/O groups) work:
noise and another set
LTI Properties
1 Create a random state-space model with one state, three inputs, and three
outputs.
2 Assign the first two inputs to a group named controls,thefirstoutput
to a group named named
measurements. Note that both InputGroup and OutputGroup are
temperature, and the last two outputs to a group
structures.
To do this, type
h = rss(1,3,3); h.InputGroup.controls=[1 2]; h.OutputGroup.temperature = [1]; h.OutputGroup.measurements = [2 3]; h
These commands result in a state-space model of the following form.
a=
x1 x2 x3 x1 -2.809 1.967 -1.82 x2 -2.432 -2.042 0.8313 x3 1.125 1.655 -1.017
b=
u1 u2 u3 x1 -0.7829 0.4801 0 x2 0 0.6682 2.309 x3 -0.2512 -0.07832 0.5246
c=
x1 x2 x3 y1 -0.01179 0 -0.2762 y2 0.9131 0.4855 1.276 y3 0.05594 -0.005005 1.863
d=
1-37
1 LT I Models
u1 u2 u3 y1 -0.5226 0 0 y2 0.1034 0 0.2617 y3 -0.8076 0 0
Input groups:
Name Channels
controls 1,2
Output groups:
Name Channels temperature 1 measurements 2,3
Continuous-time model.
Similarly, you can add or delete channels from an existing input or output group by redefining the group members, For example,
1-38
h.OutputGroup.temperature=[1 2]
addsthesecondoutputtothetemperature group. To delete a channel from a group, just respecify it. For example,
h.OutputGroup.temperature=[1]
restores the original temperature group by deleting output #2 from the group.

Time Delays

Time Delays
In this section...
“Supported Types of Delays” on page 1-39 “Available Properties for Modeling Delays” on page 1-40 “Input and Output Delays” on page 1-40 “Specifying I/O Delays in MIMO Models” on page 1-43 “Internal Delays” on page 1-45 “Analyzing Systems With Delays” on page 1-49 “Eliminating Time Delays: Padé Approximation and Thiran Filters” on
page 1-55 “Sensitivity Analysis” on page 1-60 “Specifying Delays in Discrete-Time Models” on page 1-62 “Discretization” on page 1-67 “Functions That Support Internal Time Delays” on page 1-70 “Functions That Do Not Support Internal Time Delays” on page 1-70 “Inside Time Delay Models” on page 1-71

Supported Types of Delays

You can use Control System Toolbox tools to perform accurate analysis of LTI systems with time delays. Such systems are common, particularly in process control applications. You can create, manipulate, and analyze any LTI model with a finite number of delays.
Delays can occur at
Inputs
Outputs
Between individual I/O pairs
Internally (for example, inside a feedback loop)
1-39
1 LT I Models

Available Properties f or Modeling Delays

Transfer function (TF), zero-pole-gain (ZPK), and frequency response data (FRD) objects have three properties for modeling delays:
InputDelay — Specify delays at the inputs. OutputDelay — Spe cify delays at the outputs.
IODelay — Specify independent transport delays for individual I/O pairs.
State-space (SS) objects have three properties as well:
InputDelay — Specify delays at the inputs. OuputDelay — S pe cify delays at the outputs.
InternalDelay — Keep track of delays when combining models with
internal/external delays or closing feedback loops.
Since SS objects can keep track of internal delays, state-space representation is best suited for modeling and analyzing delay effects in control systems.
1-40

Input and Output Delays

The simplest type of delays are delays in the input and output channels. The
InputDelay and OutputDelay properties let you specify such delays.
Use the
OutputDelay property to specify delays at the outputs. For example, you can
specify a first-order transfer function with deadtime (which is common in process control applications):
InputDelay property to specify delays at the model inputs and the
s
2
e
ks
()=
s
+
1
s = tf('s'); sys = 1/(s+1); sys.InputDelay = 2
Transfer function:
1
exp(-2*s) * -----
s+1
createsasystemwitha2s. delay.
Time Delays
Likewise, use the
OutputDelay property to specify output d elays. For
example:
sys.OuputDelay = 1.5;
Specifying Input and Output Delays in State-Space M odels
You can also specify state-space models with delays at the inputs or outputs. For example,
dx
dt
yt xt
can be specified with
sys1=ss(-2,1,7,0,'InputDelay',1.8)
a=
b=
xt ut
=− +
218
() ( . )
=
7
() ()
x1
x1 -2
u1
x1 1
c=
x1
y1 7
d=
u1
y1 0
Input delays (listed by ch ann el): 1.8
Continuous-time model.
1-41
1 LT I Models
The model has an input delay of 1.8 s. Similarly, to create the model:
dx
dt
yt xt
with a 1.8 s. delay at the output, use:
sys2=ss(-2,1,7,0,'OutputDelay', 1.8); sys2.OutputDelay ans =
Compare the step response of the two systems:
step(sys1,sys2); grid legend('System with input delay','System with out put delay')
xt ut
=− +
2
() ()
=−
718
() ( . )
1.8000
1-42
Time Delays
Theresponseisexactlythesameforbothsystems.Thedifferenceliesinstate trajectories. Since the y(t)’s are equal,
xt xt
12
where x1is the state of sys1,andx2is the state of sys2.
18() ( . )=−

Specifying I/O Delays in MIMO Models

You can also specify independent delays on each entry of a MIMO TF or ZPK model. Transport delays from a given input to a given output of a MIMO system are called I/O delays. For example, to create this 2-by-2 transfer function with four I/O delays:
1-43
1 LT I Models
Use exp to specify the delays and apply them to each entry:
s=tf('s'); % Laplace variable sys= exp(-s*[0.1 0.3; 0 0.2]).* ... [2/s (s+1)/(s+10); 10 (s-1 )/(s+5)]
Transfer function from inp ut 1 to output...
2
#1: exp(-0.1*s) * -
s
#2: 10
1-44
Transfer function from inp ut 2 to output...
s+1
#1: exp(-0.3*s) * ------
s+10
s-1
#2: exp(-0.2*s) * -----
s+5
Using the ioDelay Property to Specify Delays
You could also have specified the delays by setting the ioDelay property.
s=tf('s'); sys= [2/s (s+1)/(s+10); 10 (s-1)/(s+5)]; tau = [0.1 0.3; 0 0.2]; % Create I/O delay matrix. sys.ioDelay = tau; % Add I/O delays to sys.
You can retrieve the I/O delay values using the following:
sys.ioDelay
Time Delays
ans =
0.1000 0.3000 0 0.2000

Internal Delays

Using the InputDelay, Outpu tDel ay,andioDelay properties, you can model simple processes with transport delays, but you cannot model more complex situations, like a feedback loop with dela ys. In addition to the and OutputDela y properties, state-space (SS) models have an InternalDelay property, that lets you model interconnection of systems with input, output, or I/O delays, including feedback loops withdelays. Youcanusethisfeatureto accurately model and analyze arbitrary linear systems with delays. Internal delays can arise from the following:
Concatenating state-space models with input and output delays
Feeding back a delayed signal
Converting MIMO TF or ZPK models with I/O delays to state space
InputDelay
Using internal time delays, you can do the following:
In continuous time, generat e approximate-freetimeandfrequency simulations, since delays are no longer replaced by a Padé approximation. In continuous time, this allows for more accurate analysis of systems with long delays.
In discrete time, you can keep delays separate from other system dynamics. Delays are not replaced with poles at z=0, which boosts efficiency of time and frequency simulations for discrete-time systems with long delays.
Use most Control System Toolbox functions.
Test advanced control strategies for delayed systems. For example, y ou
can implement and test an accurate model of a Smith predictor. See the Smith predictor demo.
See “Inside Time Delay Models” on page 1-71 for more information about how internal delay are modeled.
1-45
1 LT I Models
Why Internal Delays Are Necessary
Why are input, output, and I/O delays not enough to model systems? Consider the simple feedback loop with a 2 s. delay:
-2s
e s+2
The closed-loop transfer function is
ss−
2
e
se
++
While the delay term in the numerator can be represented as an output delay, the delay term in the denominator cannot. In order to model the effect of the delay on the feedback loop, an additional property is needed to keep track of internal coupling between delays and ordinary dynam ics.
2
2
1-46
Building Models with Internal Delays
Typically, state-space models with internal delays are not created by specifying A, B, C, and D matrices together with a set of internal delays. Rather, build such m odels by connecting simpler LTI models (some with I/O delays) in series, parallel, or feedback. There is no limitation on how many delays are involved and how the LTI models are connected. For example, consider the following control loop, where the plant is modeled as first-order plus dead time.
Using the state-space representation, you can derive model T for th e closed-loop response from
r to y and simulate it by
P = ss(5*exp(-3.4*s)/(s+1)); C = 0.1 * (1 + 1/(5*s)); T = feedback(P*C,1)
a=
x1 x2 x1 -1.5 0.32 x2 -0.3125 0
b=
u1 x1 0.2 x2 0.125
c=
x1 x2
y1 2.5 0
d=
u1
y1 0
Time Delays
(a,b,c,d values when setti ng all internal delays to zero)
Internal delays: 3.4
1-47
1 LT I Models
Review the following considerations when you work with models with internal delays:
The software converts model from TF representation to SS.
The software fully supports feedback loops. You can wrap a feedback loop
around any system with delays.
When displaying the zero (creating a zero-order Padé approximation).
For some systems, setting delays to zero creates singular algebraic loops, which result in either improper or ill-defined, zero-delay approximations. For these systems, typing the command
A, B, C,andD matrices, the software sets all delays to
- sys returns only sizes for the matrices of a system named sys.
- sys.a produces an error.
The limited display and the error do not imply a problem with the model
sys itself.
You can create arbitrary linear systemswithdelaysusingcombinationsof state-space models and interconnection functions. Build complex models incrementally by interconnecting smaller models. You can decompose complex diagrams unless you have lumped delays (as in integral equations). After you create a system with internal delays, you can view and change the delays’ values using dot notation. For example:
sys_delay.Internaldelay
ans =
1.5000
1-48
You cannot modify the number of internal delays because they are structural properties of the model. You can, however, set the delays to 0 or change their values.
Time Delays
Analyzing Syste
You can use the us analyze systems performing suc
For example, u
step(T) grid, title('Closed-loop step response')
with delays. The software ma kesnoapproximationswhen
hanalysis.
se this code to see the closed-loop step response of
ms With Delays
ual analysis commands (
step, bode, margin, ...) to
T.
For more complicated interconnections, you can name the input and output signals of each b lock and use Suppose, for example, that you want to add feedforward to the control loop of the previous model.
connect to automatically take care of the wiring.
1-49
1 LT I Models
You can derive the corresponding closed-loop mo de l T by
F = 0.3/(s+4 P.InputNam C.InputNa F.InputNa Sum1 = sumb Sum2 = sum Tff = conn
);
e = 'u'; P.OutputName = 'y'; me = 'e'; C.OutputName = 'uc'; me = 'r'; F.OutputName = 'uf';
lk('e','r','y','+-'); % e = r-y blk('u','uf','uc','++'); % u = uf+uc ect(P,C,F,Sum1,Sum2,'r','y');
and compare its response with the feedback only design.
step(T, legend( grid title(
'b',Tff,'r') 'No feedforward','Feedforward')
'Closed-loop step response with and without feedforward')
1-50
Time Delays
Considerations to Keep in Mind when Analyzing Systems with Intern
The time and frequency responses of delay systems can look odd and suspicious to those only familiar with delay-free LTI analysis. Time responses can behave chaotically, Bode plots can exhibit gain oscillations, etc. These are not software or numerical quirks but real features of such systems. Below are a few illustrations of these phenomena.
Gain ripple:
al Time Delays
f('s');
s=t
xp(-5*s)/(s+1);
G=e
eedback(ss(G),.5);
T=f
1-51
1 LT I Models
bodemag(T)
1-52
Gain oscillations:
G = ss(1) + 0.5 * exp(-3*s); bodemag(G)
Time Delays
Jagged step response:
G = exp(-s) * (0.8*s^2+s+2)/(s^2+s); T = feedback(ss(G),1); step(T)
1-53
1 LT I Models
1-54
Note the rearrivals (echoes) of the initial step function.
Chaotic response:
G = ss(1/(s+1)) + exp(-4* s); T = feedback(1,G);
step(T)
Time Delays
You can use Control System Toolbox tools to model and analyze these and other strange-appearing artifacts of internal delays.

Eliminating Time Delays: Padé Approximation and Thiran Filters

Many control design algorithms cannot handle time delays d irectly. For example, techniques such as root locus, LQG, and pole placement do not properly if time delays are present. A common technique is to replace delays with all-pass filters that approximate the delays. To approximate time delays in:
Continuous time — use the Padé approximation.
1-55
1 LT I Models
Discrete time — use a Thiran filter.
Approximating Time Delays in Continuous Time
Use the pade command to compute Padé approximations of time delays in continuous-time systems. The Padé approximation is valid only at low frequencies. It is therefore important to compare the true and approximate responses to choose the right approximation order and check the approximation validity.
For example, consider a system with a PI controller:
Usethiscodetoimplementthesystem:
s = tf('s'); P = exp(-2.6*s)*(s+3)/(s^2+0.3*s+1); C = 0.06 * (1 + 1/s); T = feedback(ss(P*C),1);
1-56
For the PI controller, you can compare the exact closed-loop response T with the response obtained for a first-order Padé approximation of the delay:
T1 = pade(T,1); step(T,'b--',T1,'r',100) grid, legend('Exact','First-Order Pade')
Time Delays
The approximation error is large. To get a better approximation, try a second-order Padé approximation of the delay:
T2 = pade(T,2); step(T,'b--',T2,'r',100) grid, legend('Exact','Second-Order Pade')
1-57
1 LT I Models
1-58
The responses now match closely except for the nonminimum phase artifact (“wrong way” effect) introduced by the Padé a pproximation.
Approximating Time Delays in Discrete Time
When converting a continuous-time delay into discrete time, you can use the
thiran command to approximate the delay in discrete time as a Thiran
all-pass filter.
For a time delay of discrete-time transfer function that is the product of two terms:
A term representing the integer portionofthetimedelayasapureline delay, (1/z)
tau and a sampling time of Ts, thiran(tau, Ts) creates a
N
,whereN = ceil(tau/Ts).
Time Delays
A term approximating the fractional portion of the time delay (tau - NTs) as a Thiran all-pass filter.
Discretizing a Padé approximation does not guarantee good phase matching between the continuous-time delay and its discrete approximation. Using
thiran to generate a discrete-time approximation of a continuous-time delay
can yield much better phase matching. For example, the following figure shows the phase delay of a 10. 2-seco nd time delay discretized with a sample time of 1 s, approximated in three ways:
a first-order Padé approximation, discretized using the
c2d
tustin method of
an 11th-order Padé approximation, discretized using the tustin method of
c2d
an 11th-order Thiran filter
The Thiran filter yields the closest approximation of the 10.2-second delay.
See the
thiran reference page for more information about Thiran filters.
1-59
1 LT I Models
Sensitivity Ana
Delays are rarel how sensitive a c is easily perfo example, consi Loop with Dead
% Create a 3rd-order plant with a PI controller and notch filter. s = tf('s'); P = exp(-2.6*s)*(s+3)/(s^2+0.3*s+1); C = 0.06 * (1 + 1/s); T = feedback(ss(P*C),1) notch = tf([1 0.2 1],[1 .8 1]); C = 0.05 * (1 + 1/s); Tnotch = feedback(ss(P*C*notch),1);
Create fiv
tau = linspace(2,3,5); % 5 delay values Tsens = repsys(Tnotch,[1 1 5]); % 5 copies of Tnotch
Tsens(:,:,j).InternalDelay = tau(j); % jth delay value
% Use step to create an envelope plot. step(Tsens) grid title('Closed-loop response for 5 del ay values between 2.0 and 3.0')
rmed using LTI arrays and the
der this notched PI control system developed in “PI Control
e models with delay values ranging from 2.0 to 3.0:
lysis
y known accurately, so it is often important to understand
ontrol system is to the delay value. Such sensitivity analysis
InternalDelay property. For
Time” from the Analyzing Control Systems with Delays demo.
% for j=1:5
% -> jth model end
1-60
Time Delays
This plot shows that uncertainty on the delay value has little effect on closed-loop characteristics. Note that while you can change the values of internal delays, you cannot change how many there are because this is part of the model structure. To eliminate some internal delays, set their value to 0 or use
pade with order zero:
Tnotch0 = Tnotch; Tnotch0.InternalDelay = 0; bode(Tnotch,'b',Tnotch0,'r',{1e-2,3}) grid, legend('Delay = 2.6' ,'No delay','Location','SouthWest')
1-61
1 LT I Models
1-62

Specifying Delays in Discrete-Time Models

Discrete-time delays are handled in a similar way, but have some minor differences:
Discrete-time delays are always integer multiples of the sampling period.
Discrete-timedelaysareequivalenttopolesatz=0,soitisalwayspossible
to absorb delays into the model dynamics (see separate is better f or performance, es pecially for systems with long delays compared to the sampling period.
Forexample,tospecifythefirst-ordermodel
delay2z). Keeping delays
Time Delays
Hz z
25
z().=−
2
025
with sampling period Ts=0.1, and a delay of 25 sample periods, use
H = tf(2,[1 -0.95],0.1,'i nputdelay',25) step(H)
The equivalent state-space representation is:
H = ss(H) a=
x1
1-63
1 LT I Models
x1 0.95
b=
u1
x1 2
c=
x1
y1 1
d=
u1
y1 0
Input delays (listed by ch ann el): 25
Sampling time: 0.1 Discrete-time model.
1-64
Example: Discrete-Time Model with Delayed Feedback
Next, consider the feedback loop below where g is a pure g ain.
To compute the closed-loop response for g=0.01,type:
g = .01; T = feedback(g*H,1) step(T)
Time Delays
T is still a first-order model with an in tern al dela y of 25 samples. For
comparison, map all delays to poles at
T1 = delay2z(T); order(T1) ans =
26
esulting model has 26 states and is therefore less efficient to simulate.
The r
pected, however, the step responses of
As ex
step(T,'b',T1,'r--') legend('T','T1')
z=0 using delay2z:
T and T1 match exactly:
1-65
1 LT I Models
1-66
In general, it is re com mend to keep delays separate, except when analyzing the closed-loop dynamics of models with internal delays. For example:
rlocus(H)
axis([-1.25 1.25 -1.25 1.25])
Time Delays

Discretization

You can use c2d to discretize continuous-time delay systems. Available methods include zero-order hold (ZOH), first-order hold (FOH), and Tustin. For models with internal delays, the ZOH discretization is not always exact, i.e., the continuous and discretized step responses may not match:
s = tf('s'); P = exp(-2.6*s)*(s+3)/(s^2+0.3*s+1); C = 0.06 * (1 + 1/s); T = feedback(ss(P*C),1); Td = c2d(T,1); step(T,'b', Td,'r') grid, legend('Continuous','ZOH Discretization')
1-67
1 LT I Models
1-68
To correct such discretization gaps, reduce the sampling period until the continuous and discrete responses match closely:
Td = c2d(T,0.05); step(T,'b',Td,'r') grid, legend('Continuous','ZOH Discretization')
Warning: Discretization is only appro ximate due to internal delays. Use faster sampling rate i f discretizatio n error is large.
Time Delays
Note that internal delay s remain internal in th e discretized model and do not inflate the model order:
order(Td) ans =
3
For more information about discretizing systems with time delays, see “Converting Between Continuous- and Discrete-Time Representations” on page 2-24 and the
c2d reference page.
1-69
1 LT I Models
Functions That S
The following co discrete-time s
All interconne
Time domain re
Frequency dom
mmands support internal delays for both continuous- and
ystems:
ction functions
upport Internal Time Delays
sponse functions— exce pt for
ain functions—except for
impulse and initial
norm
Limitations on Functions that Support Internal Time Delays
The followi discrete-t
allmargin
only as pre
pole, zero
zero.
ssdata, g
the zero. Au enter th
ng commands support internal delays for both continuous- and
ime systems and have certain limitations:
, margin—Uses interpolation, therefore these commands are
cise as the fineness of the specified grid.
—Returns poles and zeros of the system with all delays set to
et
—If an SS model has internal delays, these commands return
,andD matrices of the system with all internal delays set to
A, B, C
gmented state-space equations keep track of which internal delays
e model.
1-70
Functi
The fol
Syste
Time-
Mode
Conv
Comp
In a del
ons That Do Not Support Internal Time Delays
lowing comm ands do not do not support time delays:
mdynamics—
domain analysis—
l simplification—
ersions—to ZPK and TF representations
ensator design—
track
lqg
ddition, the SISO Design Tool does not accept systems with internal
ays.
, lqi,andaugstate
norm and lti/isstable
initial, initialplo t, impulse,andimpulseplot
balreal, balred, minreal, modred,andsminreal
rlocus, lqg,lqry,lqrd, kalman,kalmd,lqgreg,
Time Delays
Inside Time Dela
State-space obj internal delays parts:
An ordinary st
Abankofinter
ects use generalized state-space equations to keep track of . Conceptually, such models consist of two interconnected
ate-space m odel H(s) w ith an augmented I/O set
nal delays.
yModels
The cor
responding state-space equations are:
xAxtBut Bwt
=+ +
() () ()
12
yt C xt D ut D wt
=+ +
() () () ()
11112
ttDutDwt
)() ()
zt C x
=
() (
wt zt j N
( ) ( ), ,...,
=− =
jj
++
2
21 22
1τ
You need not bother with this internal representation to use the tools. If, however, you want to extract
getDelayModel,Fortheexample:
H or the matrices A , B1,B2, ,... ,youcanuse
1-71
1 LT I Models
P = 5*exp(-3.4*s)/(s+1); C = 0.1 * (1 + 1/(5*s));
T = feedback(ss(P*C),1);
[H,tau] = getDelayModel(T,'lft'); size(H)
Note that H is a two-input, two-output model whereas T is SISO. The inverse operation (combining
setDelayModel.
H and tau to construct T)isperformedby
See [3, 4] for details.
1-72

Model Conversion

In this section...
“Available Model Formats” on page 1-73 “Explicit Conversion” on page 1-73 “Automatic Conversion” on page 1-74 “Caution About Model Conversions” on page 1-75

Available Model Formats

You can use the follow in g LTI model formats:
TF
ZPK
SS
Model Conversion
FRD
This section shows how to convert models from one format to the other.

Explicit Conversion

Model conversions are performed by tf, ss, zpk,andfrd. Given any TF, SS, or ZPK model
sys = tf(sys)
sys = zpk(sys)
sys = ss(sys)
sys = frd(sys,frequency)
Notice that FRD models can’t be converted to the other model types. In addition, you must also include a vector of frequencies ( inputargumentwhenconvertingtoanFRDmodel.
sys, the syntax for conversion to another model type is
%ConversiontoTF %ConversiontoZPK %ConversiontoSS %ConversiontoFRD
frequency)asan
1-73
1 LT I Models
For example, you can convert the state-space model
sys = ss(-2,1,1,3)
to a zero-pole-gain model by typing
zpk(sys)
This command results in
Zero/pole/gain: 3 (s+2.333)
----------­(s+2)
Note that the transfer function of a state-space m odel with data is
1-74
for continuous-time models, and
for discrete-time models.

Automatic Conversion

Some algorithms operate only on one type of LTI model. For example, the algorithm f or zero-order-hold discretization with on state-space models. Similarly, commands like type of LTI models (TF). For conv enie nce, such commands automatically convert LTI models to the appropriate or required model type. For example, in
sys = ss(0,1,1,0) [num,den] = tfdata(sys)
tfdata first converts the state-space model sys to an equivalent transfer
function in order to return numerator and denominator data.
c2d can only be performed tfdata expect one particular
Model Conversion
Conversions to state-space models are not uniquely defined. For this reason, automatic conversions to state space are disabled when the result depends on the choice of state coordinates, for examp le, i n commands like
kalman.
initial or

Caution A bout Model Conversions

When manipulating or converting LTI models, keep in mind that:
The three LTI model types TF, ZPK, and SS, are not equally well-suited for numerical computations. In particular, the accuracy of computations using high-order transfer functions is often poor. Therefore, it is often preferable to work with the state-space representation. In addition, it is often b eneficial to b alance and scale state-space models. You get this type of balancing automatically when you convert any TF or ZPK m odel to state space using
ss.
Conversions to the transfer function representation using
tf may incur a
loss of accuracy. As a result, the transfer function poles may noticeably differ from the po les of the original zero-pole-gain or state-space model.
Conversions to state space are not uniquely defined in the SISO case, nor are they guaranteed to produce a minimal realization in the MIMO case. For a given state-space model
ss(tf(sys))
sys,
may return a model with different state-space matrices, or even a different number of states in the MIMO case. Therefore, if possible, it is best to avoid converting back and forth between state-space and other model ty pe s.
1-75
1 LT I Models

Simulink Block for LTI Systems

You can incorporate LTI objects into Simulink diagrams using the LTI System block shown below.
Double-click on the block in your Simulink diagram to display or modify model information.
1-76
The LTI System block can be accessed either by typing
ltiblock
at the MATLAB prompt or by selecting Control System Toolbox from the Blocksets and Toolboxes section of the main Simulink library.
The LTI System block consists o f the dialog box shown on the right in the figure above. In the editable text box labeled LTI system variable,enter either the variable name of an LTI object located in the MATLAB workspace (for example, (for example, and discrete LTI objects in either transfer function, zero-pole-gain, or state-space form. All types of delays are supported in the LTI block. Simulink converts the model to its state-space equivalent prior to initializing the simulation.
sys) or a MATLAB expression that evaluates to an LTI object tf(1,[1 1])). The LTI System block accepts both continuous
Simulink®Block for LTI Systems
Use the editable text box labeled Initial states to enter an initial state vector for state-space models. Th e concept of "initial state" is not well -defined for transfer functions or zero-pole-gain models, as it depends on the choice of state coordinates used by the realization algorithm. As a result, you cannot enter nonzero initial states when you supply TF or ZPK models to LTI blocks in a Simulink diagram.
1-77
1 LT I Models

References

[1] Dorf, R.C. and R.H. Bishop, Modern Control Systems, Addison-Wesley, Menlo Park, CA, 1998.
[2] Wood, R.K. and M.W. Berry, "Terminal Composition Control of a Binary Distillation Column," Chemical Engineering Science, 28 (1973), pp. 1707-1717.
[3] P. Gahinet and L.F. Shampine, "Software for Modeling and Analysis of Linear Systems with Delays," Proc. American Control Conf., Boston, 2004, pp. 5600-5605
[4] L.F. Shampine and P. Gahinet, Delay-differential-algebraic Equations in Control Theory, Applied Numerical Mathematics, 56 (2006), pp. 574-588
1-78

Operations on LTI Models

“Overview” on page 2-2
“Precedence and Property Inheritance” on page 2-3
“ViewingLTISystemsasMatrices”onpage2-5
“Data Retrieval” on page 2-6
“Extracting and Modifying Subsystems” on page 2-8
“Arithmetic Operations o n LTI Models” on page 2-15
“Model Interconnection Functions” on page 2-20
2
“Converting Between Continuous- and Discrete-Time Representations”
on page 2-24
“Resampling of Discrete-Time Models” on page 2-37
“References” on page 2-41
2 O perations on LTI Models

Overview

You can perform basic matrix operations such as addition, multiplication, or concatenation on LTI models. Such operations are "overloaded," which means that they use the same syntax as they do for matrices, but are adapted to apply to LTI objects. These overloaded operations and their interpretation in this context are discussed in this chapter. You can read about discretization methods in this chapter as well.
These operations can be applied to LTI models of different types. As a result, before discussing operations on LTI models, we discuss model type precedence and how LTI model properties are inherited when models are combined using these operations. To read about how you can apply these operations to arrays of LTI models, see “Operations on LTI Arrays” on page 4-27. To read about functions for analyzing LTI models, see Chapter 3, “Model Analysis Tools”.
2-2

Precedence and Property Inheritance

You can apply operations to LTI models of different types. Operatio ns on systemsofdifferenttypesworkasfollows: theresultingtypeisdetermined by the precedence rules, and all operands are first converted to this type before performing the operation. Operations like addition and commands like
feedback operate on more than one LTI m odel at a time. If these LTI
models are represented as LTI objects of different types (for example, the first operand is TF and the second operand is SS), it is not obvious what type (for example, TF or SS) the resulting model should be. Such type conflicts are resolved by precedence rules. Specifically, TF, ZPK, SS, and FRD objects are ranked according to the precedence hierarchy.
Thus ZPK takes precedence over TF, SS takes precedence over both TF and ZPK, and FRD takes precedence over all three. In other words, any operation involving two or more LTI models produces:
Precedence and Property Inheritance
An FRD object if at least one operand is an FRD object
An SS object if no operand is an FRD object and at least one operand
is an SS object
A ZPK object if no operand is an FRD or SS object and at least one is an ZPK object
A TF object only if all operands are TF objects
For example, if then the result of their addition
sys = sys1 + sys2
is a state-space model, since state-space models have precedence over transfer function models.
To supersede the precedence rules and force the result of an operation to be a given type, for example, a transfer function (TF), you can either
Convert all operands to TF before performing the operation
sys1 is a transfer function and sys2 is a state-space model,
2-3
2 O perations on LTI Models
Convert the result to TF after performing the operation
Suppose, in the above example, you want to compute the transfer function of
sys.Youcaneitheruseaprioriconversion of the second operand
sys = sys1 + tf(sys2);
or a posteriori conversion of the result
sys = tf(sys1 + sys2)
Note These alternatives are not equivalent numerically; computations are carried out on transfer functions in the first case, and on state-space models in the second case.
Another issue is property inheritance, that is, how the operand property values are passed on to the result of the operation. While inheritance is partly operation-dependent, some general rules are summarized below:
2-4
In operations combining discrete-time LTI models, all models must have identical or unspecified ( from such operations inherit the specified sample time, if there is one.
Most operations ig nore the
In general, when two LTI models
operations such as model inherits its I/O names and I/O groups from conflicting I/O names or I/O groups are not inherited. For example, the
InputName property for sys1 + sys2 is left unspecified if sys1 and sys2
have different InputName property values.
A model resulting from operations on TF or ZPK models inherits its
Variable property value from the operands. Conflicts are resolved
according the follow ing rules:
sys.Ts = -1) sample times. Models resulting
Notes and Userdata properties.
sys1 and sys2 are combined using
+, *, [,], [;], append,andfeedback,theresulting
sys1 an d sys2. However,
- For continuous-time models, 'p' has precedence over 's'.
- For discrete-time models, 'z^-1' has precedence over 'q' and 'z',
while
'q' has precedence over 'z'.

Viewing LTI Systems as Matrices

In the frequency domain, an LTI system is represented by the linear input/output map
Viewing LTI Systems as Matrices
This map is ch Laplace or Z­outputs, so t
If you think operations For exampl be express
sys = sys1 + sys2
because p Similar matrix-
provid the thi
ly, subsystems of a given LTI model like subscripting. For instance,
sys(3,1:2)
es the I/O relation between the first two inputs (column indices) and
rd output (row index), which is consistent with
aracterized by its transfer matrix H, a function of either the
transform variable. The transfer matrix H maps inputs to
here are as many columns as inputs and as many rows as outputs.
of LTI systems in terms of (transfer) matrices, certain basic
on LTI systems are naturally expressed with a matrix-like syntax.
e, the parallel connection of two LTI systems
ed as
arallel connection amounts to adding the transfer matrices.
sys can be extracted using
sys1 and sys2 can
for .
2-5
2 O perations on LTI Models

Data Retrieval

The functions tf, zpk, ss,andfrd pack the model data and sample time in a single LTI object. Conversely, the following commands provide convenient data retrieval for any type of TF, SS, or ZPK model
[num,den,Ts] = tfdata(sys) % Ts = sample time [z,p,k,Ts] = zpkdata(sys) [a,b,c,d,Ts] = ssdata(sys) [a,b,c,d,e,Ts] = dssdata(sys) [response,frequency,Ts] = frdata(sysfr)
sys,orFRDmodelsysfr.
Note that:
sys can be any type of LTI object, except an FRD model sysfr,theinputargumenttofrdata, can only be an FRD model
You can use any variable names you want in the output argument list of any of these functions.
2-6
The output arguments to
zpkdata, are cell arrays, even in the SISO case. These cell arrays have
num an d den assigned to tfdata,andz and p assigned
as many rows as outputs, as many columns as inputs, and their ijth entry specifies the transfer function from the jth input to the ith output. For example,
H = [tf([1 -1],[1 2 10]) , tf(1,[1 0])]
creates the one-output/two-input transfer function
Typing
m,den] = tfdata(H);
[nu
{1,1}, den{1,1}
num
Loading...