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 2001Online onlyNew for Version 5.1 (Release 12.1)
July 2002Online onlyRevised for Version 5.2 (Release 13)
June 2004Online onlyRevised for Version 6.0 (Release 14)
March 2005Online onlyRevised for Version 6.2 (Release 14SP2)
September 2005 Online onlyRevised for Version 6.2.1 (Release 14SP3)
March 2006Online onlyRevised for Version 7.0 (Release 2006a)
September 2006 Online onlyRevised for Version 7.1 (Release 2006b)
March 2007Online onlyRevised for Version 8.0 (Release 2007a)
September 2007 Online onlyRevised for Version 8.0.1 (Release 2007b)
March 2008Online onlyRevised for Version 8.1 (Release 2008a)
October 2008Online onlyRevised for Version 8.2 (Release 2008b)
March 2009Online onlyRevised for Version 8.3 (Release 2009a)
September 2009 Online onlyRevised for Version 8.4 (Release 2009b)
March 2010Online onlyRevised for Version 8.5 (Release 2010a)
Square-root solver for discrete-time
Lyapunov equations
Generalized solver for
continuous-time algebraic Riccati
equation
gdare
lyap
lyapchol
Generalized solver for discrete-time
algebraic Riccati equation
Solve continuous-time Lyapunov
equation
Square-root solver for
continuous-time Lyapunov equation
1-13
1 Function Reference
Preferences
ctrlprefSet Control System Toolbox™
preferences
Visualization of Model Dynamics and Responses
bodeplot
hsvplotPlot Hankel singular values and
impulseplotPlot impulse response and return
initialplotPlot initial condition response and
iopzplot
ngrid
nicholsplot
nyquistplot
pzplot
rlocusplotPlot root locus a nd return plot
Plot Bode frequency response and
return plot handle
return plot handle
plot handle
return plot handle
Plot pole-zero map for I/O pairs and
return plot handle
Superimpose Nichols chart on
Nichols plot
Plot Nichols frequency responses
and return plot handle
Plot Nyquist frequency responses
and return plot handle
Plot pole-zero map of LTI model and
return plot handle
handle
1-14
sgrid
Generate s-plane grid of constant
damping factors and natural
frequencies
Plot Customization
sigmaplot
stepplot
zgrid
Plot Customization
bodeoptions
getoptionsReturn
hsvoptions
nicholsoptions
pzoptions
setoptions
Plot singular values of frequency
response and return plot handle
Plot step response o f LTI systems
and return plot handle
Generate z-plane grid of constant
damping factors and natural
frequencies
Create list of Bode plot options
@PlotOptions handle or plot
options property
Create list of Hankel singular value
plot options
Create list of Nichols plot options
Create list of pole/zero plot options
Set plot options for response plot
sigmaoptions
timeoptions
Create list of singular-value plot
options
Create list of time plot options
1-15
1 Function Reference
Help
ltimodelsHelp on LTI models
ltipropsHelp on LTI mode
l properties
1-16
Functions — Alphabetical
List
2
abs
PurposeEntrywise magnitude of frequency response
Syntaxabsfrd = abs(sys)
Descriptionabsfrd = abs(sys) computes the magnitude of the frequency response
contained in the FRD model
is computed for each entry. The output
containing the magnitude data across frequencies.
See Alsobodemag, sigma, frd/imag, frd/real, fnorm
sys. For MIMO models, the magnitude
absfrd is an FRD object
2-2
PurposePole placement design for single-input systems
Syntaxk = acker(A,b,p)
Descriptionk = acker(A,b,p)
Given the single-input system
xAxbu=+
and a vector p of desired closed-loop pole locations, acker (A,b,p) uses
Ackermann’s formula [1] to calculate a gain vector
state feedback u = −kx places the closed-loop poles at the locations
In other words, the eigenvalues of A − bk match the entries o f
ordering). Here
state transmission vector.
A is the state transmitter matrix and b is the input to
acker
k such that the
p.
p (up to
You can also use
matrix
A and substituting c' for b when y = cx is a single output.
l = acker(a',c',p).'
acker for estimator gain selecti on by transposing the
Limitationsacker is limited to single-input systems and the pair (A, b)mustbe
controllable.
Note that this method is not numerically reliable and starts to break
down rapidly for problems of order greater than 5 or for weakly
controllable systems. See
alternative.
place for a more general and reliable
References[1] Kailath, T., Linear Systems,Prentice-Hall,1980,p.201.
See Alsolqr, place, rlocus
2-3
allmargin
PurposeAll crossover frequencies and corresponding stability margins
SyntaxS = allmargin(sys)
s = allmargin(mag,phase,w,ts)
DescriptionS = allmargin(sys)
allmargin
corresponding crossover frequencies of the SISO open-loop model
allmargin is applicable to any SISO model, including models with
delays.
The output
•
GMFrequency — All -180 degree crossover frequencies (in rad/s)
GainMargin — Corresponding gain margins, defined as 1/G where
•
G is the gain at crossover
•
PMFrequency — All 0 dB crossover frequencies in rad/s
PhaseMargin — Corresponding phase margins in degrees
•
DMFrequency and DelayMargin — Critical frequencies and the
•
corresponding delay margins. Delay margins are given in seconds
for continuous-time systems and multiples of the sample time for
discrete-time systems.
• Stable — 1 if the nom inal closed-loop system is stable, 0 otherwise.
In general, stability cannot be assessed for FRD system. In any case
when stability cannot be assessed,
s = allmargin(mag,phase,w,ts) computes the stability margins from
the frequency response data
allmargin expects frequency values w in rad/s, magnitude values mag in
linear scale, and phase values
between frequency points to approximate the true stability margins.
computes the gain, phase, and delay margins and the
sys.
S is a structure with the following fields:
S is set to NaN.
mag, phase, w, and the sampling time, ts.
phase in degrees. Interpolation is used
See Alsoltimodels, ltiview, margin
2-4
PurposeGroup LTI models by appending the ir inputs and outputs
Syntaxsys = append(sys1,sys2,...,sysN)
Descriptionsys = append(sys1,sys2,...,sysN)
append
append
to form the augmented model sys depicted below.
For systems with transfer functions H1(s),...,HN(s), the resulting
system
appends the inputs and outputs of the LTI models sys1,...,sysN
sys has the block-diagonal transfer function
Hs
()
⎡
1
⎢
0
⎢
⎢
⎢
00
⎣
00
Hs
()
2
…
⎤
⎥
⎥
⎥
0
⎥
Hs
()
N
⎦
For state-space models sys1 and sys2 with data (A1, B1, C1, D1)and
(A
, B2, C2, D2), append(s ys1, sys2) produces the following state-space
2
model:
2-5
append
x
⎡
⎢
x
⎣
yy
⎡
⎢
y
⎣
ArgumentsThe input arguments sys1,..., sysN can be LTI models of any type.
Regular matrices are also accepted as a representation of static gains,
butthereshouldbeatleastoneLTIobjectintheinputlist. TheLTI
models should be either all continuous, or all discrete with the same
sample time. When appending models of different types, the resulting
type is determined by the precedence rules (see “Precedence and
Property Inheritance” for details).
Description[sysb, g] = bal real (sys) computes a balanced realization sysb
for the stable portion of the LTI model sys. balre al handles both
continuous and discrete systems. If
first and automatically converted to state space using
sys is not a state-space model, it i s
ss.
For stable systems,
sysb is an equivalent realization for which the
controllability and observability Gramians are equal and diagonal, their
diagonal entries for ming the vector G of Hankel singular values. Small
entries in G indicate states that can be removed to simplify the model
(use
modred to reduce the model order).
sys has unstable poles, its stable part is isolated, balanced, and added
If
back to its unstable part to form
to unstable modes are set to
specifies additional options for the stable/unstable decomposition. See
the
stabsep reference page for more information about these options.
The default values are
[sysb, g] = bal real (sys, condmax) controls the condition number
of the stable/unstable decomposition. Increasing
ATOL = 0, RTOL = 1e-8,andALPHA = 1e-8.
condmax helps
separate close by stable and unstable modes at the expense of accuracy.
By default
[sysb, g, T, Ti] = balreal(sys) also returns the vector g
condmax=1e8.
containing the diagonal of the balanced gramian, the state similarity
2-9
balreal
transformation xb= Tx used to convert sys to sysb, and the inverse
transformation Ti = T
-1
.
If the system is normalized properly, the diagonal
canbeusedtoreducethemodelorder. Because
controllability and observability of i ndividual states of the balanced
model, you can delete those states with a small
the most important input-output characteristics of the original system.
Use
modred to perform the state elimination.
[sysb, g] = bal real (sys, opts) computes the balanced realization
using the options specified in the
There are also overloaded methods available. Type
help ss/balreal
help lti/balreal
help idmodel/balreal
for more information.
Example 1Consider the zero-pole-gain model
sys = zpk([-10 -20.01],[- 5 -9.9 -20.1],1)
Zero/pole/gain:
(s+10) (s+20.01)
---------------------(s+5) (s+9.9) (s+20.1)
g of the joint gramian
g reflects the combined
g(i) while retaining
hsvdOptions object opts.
2-10
A state-space realization with balanced gramians is obtained by
[sysb,g] = balreal(sys)
The diagonal entries of the joint gramian are
g'
ans =
balreal
0.10060.00010.0000
which indicates that the last two states of sysb are weakly coupled to
the input and output. You can then delete these states by
sysr = modred(sysb,[2 3],'del')
to obtain the following first-order approximation of the original system.
zpk(sysr)
Zero/pole/gain:
1.0001
-------(s+4.97)
Compare the Bode responses of the original and reduced-order models.
bode(sys,'-',sysr,'x')
2-11
balreal
2-12
Exampl
e2
Create
Apply balreal to create a balanced gramian realization.
this unstable system:
sys1=tf(1,[1 0 -1])
Transfer function:
1
------s^2 - 1
[sysb,g]=balreal(sys1)
a=
x1x2
x110
x20-1
b=
u1
x10.7071
x20.7071
c=
x1x2
y10.7071-0.7071
balreal
d=
u1
y10
Continuous-time model.
g=
Inf
0.2500
TheunstablepoleshowsupasInf in vector g.
AlgorithmConsider the model
xAxBu
=+
yCxDu
=+
2-13
balreal
with controllability and observability gramians Wcand Wo.Thestate
coordinate transformation
xTx=
produces the equivalent model
xTATxTBu
yCTxDu
−−1
=+
1
=+
and transforms the gramians to
−−
WTWT WTWT
==
ccTo
,
T
1
o
The function balreal computes a particular similarity t ra nsformation
T such that
of System Balancing Transformations and Other Applications of
Simultaneous Diagonalization Algorithms," IEEEControl, AC-32 (1987), pp. 115-122.
[2] Moore, B., "Principal Component Analysis in Linear Systems:
Controllability, Observability, and Model Reduction," IEEETransactions on Automatic Control, AC-26 (1981), pp. 17-31.
[3] Laub, A.J., "Computation of Balancing Transformations," Proc.
Descriptionrsys = balred(sys, ORDERS) computes a reduced-o rde r
approximation
of states) for
at once by setting
is a vector of reduced-order models. Use hsvd to plot the Hankel
singular values and pick an adequate approximation order. States w ith
relatively small Hankel singular values can be safely discarded.
rsys of the LTI model sys. The desired order (number
rsys is specified by ORDERS. You can try multiple orders
ORDERS to a vector of integers, in which case rsys
balred
When
and unstable parts using
approximated. Use
'RelTol', RTOL, 'Offset', ALPHA)
the stable/unstable decomposition. See
values are
rsys = balred(sys, ORDERS, ..., 'E limination',METHOD)
sys has unstable poles, it is first decompose d into its stable
stabsep, and only the stable part is
sys = balred(sys, ORDERS, 'AbsTol', A TOL,
to specify additional options for
stabsep for details. The default
ATOL=0, RTOL=1e-8,andALPHA=1e-8.
specifies the sta t e elimination method. Avail a bl e choices for METHOD
include:
•
'MatchDC': Enforce matching DC gains (default)
'Truncate': Simply discard the states associated with small Hankel
•
singular values. The
'Truncate' method tends to produce a better
approximation in the frequency domain, but the DC gains are not
guaranteed to match.
rsys = balred(sys, ORDERS, ..., 'B alancing', BALDATA) makes
use of the balancing data
BALDATA produced by hsvd.Becausehsvd does
2-15
balred
most of the work needed to compute rsys,thissyntaxismoreefficient
when using
balred uses implicit balancing techniques to compute the reduced-
order approximation
rsys = balred(sys, ORDERS, opts) computes the model reduction
using the options specified in the
hsvd and balred jointly.
rsys.
balredOptions object opts.
There is more than one
help lti/balred
for more information.
Note The order of the approximate model is always at least the number
of unstable poles and at most the minimal order of the original model
(number
relative threshold)
NNZ of nonzero Hankel singular values using an eps-level
balred method available. Type
References[1] Varga, A., "Balancing-Free Square-Root Algorithm for Computing
Singular Perturbation Approximations," Proc. of 30th IEEE CDC,
Brighton, UK (1991), pp. 1062-1065.
See AlsobalredOptions, hsvd, lti/ orde r, minreal, sminreal
2-16
balredOptions
PurposeCreate option set for model order reduction
Syntaxopts = balredOptions
opts = balredOptions('OptionName', OptionValue)
Descriptionopts = balredOptions returns the default option set for the balred
command.
opts = balredOptions('OptionName', OptionValue) accepts one or
more comma-separated name/value pairs. Specify
single quotes.
OptionName inside
Input
Arguments
Name/Value Pairs
StateElimMethod
State elimination method. Specifies how to eliminate the weakly
coupled states (states with smallest Hankel singular values).
Specified as one of the following values:
'MatchDC'
'Truncate'
Default:
AbsTol, RelTol
Absolute and relative error tolerance for stable/unstable
decomposition. Positive scalar values. For an input model G
with unstable poles,
by computing the stable/unstable decomposition G → GS + GU.
The
AbsTol and RelTol tolerances control the accuracy of this
decomposition by ensuring that the frequency responses of G
Discards the specified states and alters the
remaining states to preserve the D C gain.
Discards the specified states without altering the
remaining states. This method tends to product
a better approximation in the frequency domain,
but the DC gains are not guaranteed to match.
'MatchDC'
balred first extracts the stable dynamics
2-17
balredOptions
and GS + GU differ by no more than AbsTol + RelTol*abs(G).
Increasing these tolerances helps separate nearby stable and
unstable modes at the expense of accuracy. See
information.
stabsep for more
Default:
Offset
Offset for the stable/unstable boundary. Positive scalar value. In
the stable/unstable decomposition, the stable term includes only
poles satisfying
Descriptionbode computes the magnitude and phase of the frequency response
of LTI models. When you invoke this function without left-side
arguments,
is plotted in decibels (dB), and the phase in degrees. The decibel
calculation for
the system’s frequency response. You can use bode plots to analyze
system properties such as the gain margin, phase margin, DC gain,
bandwidth, disturbance rejection, and stability.
bode produces a Bode plot on the screen. The magnitude
mag is computed as 20log
(|H(jω)|), where |H(jω)| is
10
2-24
bode(sys) plots the Bode response of an arbitrary LTI model sys.
This model can be continuous or discrete, and SISO or MIMO. In the
MIMO case,
bode produces an array of Bode plots, each plot showing
the Bode response of one particular I/O channel. The frequency range is
determined automatically based on the system poles and zeros.
bode(sys,w) explicitly specifies the frequency range or frequency points
for the plot. To focus on a particular frequency interval
set
w = {wmin,wmax}. To use particular frequency points, set w to the
vector of desired frequencies. Use
logspace to generate logarithmically
[wmin,wmax],
spaced frequency vectors. S pecify all frequencies in radians per second
(rad/s).
bode(sys1,sys2,...,sysN) or bode(sys1,sys2,...,sysN,w) plots
the Bode responses of several LTI models on a single figure. All systems
must have the same number of inputs and outputs, but they can include
both continuous and discrete systems. Use this syntax to compare the
Bode responses of multiple systems.
bode
bode(sys1,'PlotStyle1',...,sysN,'PlotStyleN') specifies the
color, linestyle, and/or marker for each system’s plot. For example:
bode(sys1,'r--',sys2,'gx')
produces a red dashed lines for the first system sys1 and green 'x'
markers for the second system sys2.
When you invoke this function with left-side arguments, the commands
return the magnitude and phase (in degrees) of the frequency response
at the frequencies
arrays with the frequency as the last dimension (see "Arguments" for
details). To convert the magnitude to decibels, type
magdb = 20*log10(mag)
w (in rad/s). The outputs mag and phase are 3-D
RemarksYou can change the properties of your plot, for example the units. For
information on the ways to change properties of your plots, see “Ways
to Customize Plots”.
ArgumentsThe output arguments mag and phase are 3-D arrays with dimensions
()()()number of outputsnumber of inputslength of w××
For SISO systems, mag(1,1,k) and phase(1,1,k) give the magnitude
and phase of the response at the frequency ω
magkh j
(,, ) | ()|
1111=
phasekh j
(,, )()
=∠
k
k
MIMO systems are treated as arrays of SISO systems and the
magnitudes and phases are computed for each SISO entry h
independently (hijis the transfer function from input j to output i). The
= w(k).
k
ij
2-25
bode
values mag(i,j,k) and phase(i,j,k) then characterize the response of
h
at the frequency w(k).
ij
mag i j khj
(, , ) | ()|
=
phase i j khj
(,,)()
ExampleYou can plot the Bode response of the continuous SISO system
2
Hs
()
by typing
g = tf([1 0.1 7.5],[1 0.12 9 0 0]);
bode(g)
ss
=
432
sss
++
ijk
=∠
0175
..
++
0129
.
ijk
2-26
bode
To plot the response on a wide r frequency range, for example , from
0.1 to 100 rad/s, type
bode(g,{0.1 , 100})
You can also discretize this system using zero-order hold and the sample
time T
responses by typing
= 0.5 second, and compare the continuous and discretized
s
gd = c2d(g,0.5)
bode(g,'r',gd,'b--')
Algo
rithm
ode
The b
eval
pole
command computes the ZPK representation of the model and
uates the gain and phase of the frequency response from the zero,
, gain data for each I/O pair.
2-27
bode
For continuous-time models, the bode command e valuates the frequency
response on the imaginary axis s = jω and only considers po sitive
frequencies.
For discrete-time models, the
bode command evaluates the frequency
response on the unit circle. To facilitate interpretation, the command
parameterizes the upper half of the unit circle as
jT
ze
s
=≤≤=
,0
N
T
s
where Tsis the sample time. ωNis called the Nyquist frequency.The
equivalent continuous-time frequency ω is then used as the x-axis
jT
variable. Because
He
s
()
is periodic with pe riod 2 ωN,thebode
command plots the response only up to the Nyquist frequency ωN.Ifyou
do not specify a sa mple time, this value defaults to T
=1.
s
DiagnosticsIf the system has a pole on the jω axis (or unit circle in the discrete
case) and
produces a w arning message.
w contains this frequency point, the gain is infinite and bode
See Alsobodeoptions, evalfr, freqresp, ltiview, nichols, nyquist, sigma
Descriptionbodemag(sys) plots the magnitude of the frequency response of the LTI
model SYS (Bode plot without the phase diagram). The frequency range
and number of points are chosen automatically.
bodemag(sys,{wmin,wmax}) draws the magnitude plot for frequencies
between
bodemag(sys,w) uses the user-supplied vector W of frequencies, in
radians/second, at which the frequency response is to be evaluated.
bodemag(sys1,sys2,...,sysN,w) shows the frequency response
magnitude of several LTI models
The frequency vector
style, and marker for each model, as in
wmin and wmax (in radians/second).
sys1,sys2,...,sysN on a single plot.
w is optional. You can also specify a color, line
bodemag(sys1,'r',sys2,'y--',sys3,'gx').
See Alsobode, ltiview, ltimodels
2-29
bodeoptions
PurposeCreate list of Bode plot options
SyntaxP = bodeoptions
P = bodeoptions('cstprefs')
DescriptionP = bodeoptions returns a list of available options for Bode plots with
default values set. You can use these options to customize the Bode plot
appearance using the command line.
P = bodeoptions('cstprefs') initializes the plot options you sele cted
in the Control System Toolbox Preferences Editor. For more information
about the editor, see “Toolbox Preferences Editor” in the User’s Guide
documentation.
This table summarizes the Bode plot options.
OptionDescription
Title, XLabel, Y La belLabel text and style
TickLabelTick label style
2-30
Grid [off|on]Show or hide the grid
XlimMode, YlimModeLimit modes
Xlim, Ylim
IOGrouping
[none|inputs|output|all]
InputLabels, OutputLabels
InputVisible, OutputVisibleVisibility of input and output
FreqUnits [Hz|rad/s]Frequency units
FreqScale [linear|log]
MagUnits [dB|abs]Magnitude units
MagScale [linear|log]
Axes limits
Grouping of input-output pairs
Input and output label styles
channels
Frequency scale
Magnitude scale
OptionDescription
bodeoptions
MagVisible [on|off]
MagLowerLimMode
Magnitude plot visibility
Enables a lower magnitude limit
[auto|manual]
MagLowerLim
Specifies the lower magnitude
limit
PhaseUnits [deg|rad]Phase units
PhaseVisible [on|off]
PhaseWrapping [on|off]
PhaseMatching [on|off]
PhaseMatchingFreq
Phase plot v isi bility
Enables phase wrapping
Enables phase matching
Frequency for matching phase
PhaseMatchingValueThe value to which phase
responses are matched closely
ExamplesIn this example, set phase visibility and frequency units in the Bode
plot options.
P = bodeoptions; % Set phase visiblity to off and frequency units to Hz in options
P.PhaseVisible = 'off';
P.FreqUnits = 'Hz'; % Create plot with the options specified by P
h = bodeplot(tf(1,[1,1]),P);
The following plot is created, with the phase plot visibility turned off
and the frequency units in Hz.
2-31
bodeoptions
See Alsobode, bodeplot, getoptions, setoptions
2-32
bodeplot
PurposePlot Bode frequency response a nd return plot handle
Descriptionsysd = c2d(sys, Ts) discretizes the continuous-time LTI model sys
using zero-order hold on the inputs and a sample time of Ts seconds.
sysd = c2d(sys, Ts,'method') discretiz es sys using the specified
discretization method
sysd = c2d(sys, Ts, opts) discretizes sys using the option set opts,
specified using the
[sysd, G] = c2d (sys , Ts[, ’method’]) returns a matrix, G that
maps the continuous initial conditions x
sys to the discrete-time initial state vector x [0]. G is computed using
the specified discretization method
if you omit
[sysd, G] = c2d (sys , Ts, opts).
'method'. To specify additional discretization options, use
'method'.
c2dOptions command.
0
'method', or using zero-order hold
and u0of the state-space model
c2d
Tips• Use the syntax sysd = c2d(sys, Ts, 'method') to discretize
sys using the default options for'method'. To specify additional
Input
Arguments
discretization options, use the syntax
• To specify the
known as the
of
c2dOptions.
sys
tustin method with frequency prewarping (formerly
'prewarp' method), use the PrewarpFrequency option
Continuous-time LTI model. sys can be a tf, zpk, ss,orfrd
model representing a SISO or MIMO system. (The 'matched'
discretization method supports SISO systems only.) sys can have
input/output or internal time delays; however, the
and 'impulse' methods do not support state-space models with
sysd = c2d(sys, Ts, opts) .
'matched'
2-37
c2d
internal time delays. For the syntax [sysd, G] = c2d(sys, Ts,
[opts])
Ts
, sys must be a state-space model.
Sample time in seconds.
method
String specifying a discretization method:
•
'zoh' — Zero-order hold (default). Assumes the control inputs
Assumes the control inputs are piecewise linear over the
sampling period
'impulse' —Impulseinvariant discretization.
•
'tustin' — Bilinear (Tustin) method.
•
'matched' — Zero-pole matching method.
•
Ts.
Output
Arguments
2-38
For more information about discretization methods, see
“Converting Between Continuous- and Discrete-Time
Representations” in the Control System Toolbox User’s Guide and
the
c2dOptions reference page.
opts
Discretization options. C reate opts using the c2dOptions
command.
sysd
Discrete-time model of the same type as the input system sys.
G
Matrix relating continuous-time initial conditions x0and u0of
the state-space model
sys to the discrete-time initial state vector
x [0], as follows:
x
⎡
⎤
xG
=⋅
0
[]
0
⎢
⎥
u
0
⎣
⎦
For state-space models with time delays, c2d pads the matrix
G with zeroes to account for additional states introduced by
discretizing those delays. See “Converting Between Continuousand D iscrete-Time Representations” for a discussion of modeling
time delays in discretized systems.
ExamplesDiscretize the continuous-time transfer function:
s
−
Hs
=
()
with input delay Td= 0 .35 second. To discretize this system using the
triangle (first-order hold) approximation with sa m ple time T
second, type
H = tf([1 -1], [1 4 5], 'inputdelay', 0.35);
Hd = c2d(H, 0.1, 'foh'); % discretize with FOH method an d
The next command compares the continuous and discretized step
responses.
step(H,'-',Hd,'--')
2-39
c2d
2-40
Discret
ize the delayed transfer function
10
s
−025
Hs e
()
.
=
2
310
ss
++
using zero-order hold on the input, and a 10-Hz sampling rate.
h=tf(
hd = c2
10,[1 3 10],'iodelay',0.25); % create transfer function
d(h, 0.1) % zoh is the default method
These commands produce the discrete-time transfer function
sfer function:
Tran
1187 z^2 + 0.06408 z + 0.009721
0.0
-3) * ----------------------------------
z^(
- 1.655 z + 0.7408
z^2
Sampling time: 0.1
In this example, the discretized model hd has a delay of three sampling
periods. The discretization algorithm absorbs the residual half-period
delay into the coefficients of
Compare the step responses of the continuous and discretized models
using
step(h,'--',hd,'-')
hd.
c2d
Discretize a state-space model withtimedelay,usingaThiranfilter
to model fractional delays:
sys = ss(tf([1, 2], [1, 4, 2]));%create a state-space model
sys.InputDelay = 2.7%add input delay
2-41
c2d
This command creates a continuous-time state-space model with two
states, as the output shows:
a=
x1x2
x1-4-2
x210
b=
u1
x12
x20
c=
x1x2
y10.51
d=
u1
y10
2-42
Input delays (listed by ch ann el): 2.7
Continuous-time model.
Use c2dOptio ns to create a set of discretization options, and discretize
the model. This example uses the Tustin discretization method.
The discretized model now contains three additional states x3, x4,
and
x5 corresponding to a third-order Thiran fil ter. Sin ce the time
delay divided by the s ampling time is 2.7, th e third-order Thiran filter
(
FractDelayApproxOrder = 3) can approximate the entire time delay.
See “Tustin Approximation and Zero-Pole Matching Methods” o n page
2-45.
AlgorithmZOH, FOH, and Impulse-Invariant Methods
The ZOH, FOH, and impulse-invariant methods produce exact
discretizations inthetimedomainfor:
• systems without time delays
2-43
c2d
• systems with time delays on the inputs and outputs only (no internal
delays)
Because of the exact match, you can use these discretization methods
for time-domain simulations. In this context, exact discretization means
that the time responses of the continuous and discretized models match
exactly for the following classes of input signals:
• Staircase inputs for ZOH
• Piecewise linear inputs for FOH
• Impulse trains for impulse IMP
For systems with internal delay s (delays in feedback loops), the ZOH
and FOH methods result in approximate discretizations. An internal
delay is illustrated in the following figure:
H(s)
2-44
-ts
e
For such systems, c2d performs the following actions to compute an
approximate ZOH or FOH discretization:
1 Decomposes the delay τ as
2 Absorbs the fractional delay
3 Discretizes H (s)toH(z).
4 Represents the integer portion of the delay kT
discrete-time delay z
–k
τρ=+kT
s
into H(s).
ρ
. The final discretized model appears in the
with
0 ≤<ρT
s
as an internal
s
.
following figure:
H(z)
r
H(s)e
The impulse-invariant method does not support systems with internal
delays.
For more information about working with systems that have time
delays, see “Time Delays” in the Control System Toolbox User’s Guide.
documentation.
For more information about the ZOH, FOH, and impulse-invariant
discretization methods, see “Converting Between Continuous- and
Discrete-Time Representations” in the Control System Toolbox User’sGuide.
-s
-k
z
c2d
Tustin Approximation and Zero-Pole Matching Methods
When discretizing a system with time delays, the tustin and matched
methods:
• Round any tim e delay to the nearest m ul t ip le of the sampling time, if
the
FractDelayApproxOrder option of c2dOptions is 0.
• Approximate the fractional time delay by a Thiran filter of order u p
to
FractDelayApproxOrder,forFractDelayAppro xOrd er >0.
For example, the following figure illustrates a general SISO state-space
model H(s). H(s)hasinputdelayτ
,outputdelayτo, and internal delay τ.
i
2-45
c2d
The following figure shows the general result of discretizing the
state-space model using the
the general result is similar, except that the
tustin method. (For the matched method,
matched method does not
support internal delays.)
2-46
If Frac
the ti
are co
of the
m =ro
If
port
Fra
app
tDelayApproxOrder = 0
me delays to pure integer time delays. The resulting delays
mputed by rounding the time delay to the nearest multiple
sample time T
und(τ/T
actDelayApproxOrder > 0
Fr
).. In this case, Fi(z)=Fo(z)=F(z)=1.
s
: mi= round(τi/Ts), mo= round(τo/Ts), and
s
ion of the time delays by Thira n filters F
ctDelayApproxOrder
determines how much of the total delay c2d
roximatedbythefractionaldelayfilter, and how much is realized by
(its default value), c2d converts
,thenc2d approximates the fractional
(z), Fo(z), and F(z).
i
a chain of unit delays. For example, for the input delay τi,theorderof
the Thiran filter F
(z)is:
i
c2d
order(F
If ceil(τ
F
(z) approximates the entire input delay τi.Ifceil(τi/Ts)>
i
FractDelayApproxOrder, the Thiran filter only approximates a portion
of the input delay. In that case,
input delay as a chain of unit delays z
m
c2d uses T hiran filters and FractDelayApproxOrder in a similar way to
approximate the output delay τ
When discretizing
(z)) = max(ceil(τi/Ts), Fra ctDe layApproxOrder).
i
)<FractDelayApproxOrder,theThiranfilter
i/Ts
c2d represents the remainder of the
–m
,where
i
=ceil(τi/Ts)–FractDelayApproxOrder.
i
and the internal delay τ.
o
tf and zpk models using the tus tin or matched
methods, c2d first aggregates all input, output, and i/o delays into a
single i/o delay τ
for each channel. c2d then approximates τ
TOT
TOT
as a
Thiran filter and a chain of unit delays in the same way as described for
each of the time delays in
For more information about Thiran filters, see the
ss models.
thiran reference
page.
For more information about the Tustin and zero-pole matching
discretization methods, see “Converting Between Continuous- and
Discrete-Time Representations” in the Control System Toolbox User’sGuide.
References[1] Franklin, G.F., Powell, D.J., and Workman, M.L., Digital Control of
Dynamic Systems (3rd Edition), Prentice Hall, 1997.
[2] L.F. Shampine and P. Gahinet, "Software for Modeling and Analysis
of Linear Systems with Delays," Proceedings of the American ControlConference, 2004.
See Alsoc2dOptions, d2c, d2d, thiran
2-47
c2dOptions
PurposeCreate option set for continuous- to discrete-time conversions
Syntaxopts = c2dOptions
opts = c2dOptions('OptionName', OptionValue)
Descriptionopts = c2dOptions returns the default options for c2d.
opts = c2dOptions('OptionName', OptionValue) accepts one or
more comma-separated name/value pairs that specify options for the
c2d command. Specify OptionName inside single quotes.
Input
Arguments
Name/Value Pairs
Method
Discretization method, specified as one of the following values:
'zoh'
'foh'
'impulse'
Zero-order hold, where c2d assumes the control
inputs are piecewise constant over the sampling
period
Triangle approximation (modified first-order
hold), where
piecewise linear over the sampling period
(See [1], p. 228.)
Impulse-invariant discretization.
Ts.
c2d assumes the control inputs are
Ts.
2-48
c2dOptions
'tustin'
Bilinear (Tustin) approximation. By default,
c2d discretizes with no prewarp and rounds
any fractional time delays to the nearest
multiple of the samp le time. To include
prewarp, use the
PrewarpFrequency option.
To approximate fractional tim e delays, use
the
FractDelayApproxOrder option.
'matched'
Zero-pole matching method. (See [1], p. 224.)
By default,
c2d rounds any fractional time
delays to the nearest multiple of the sample
time. To approximate fractional time delays, use
the
FractDelayApproxOrder option.
Default:
PrewarpFrequency
'zoh'
Prewarp frequency for 'tustin' method, specified in radians per
second. Takes positive scalar values. A value of 0 corresponds to
the s tandard
'tustin' method without prewarp.
Default: 0
FractDelayApproxOrder
Maximum order of the Thiran filter used to approximate fractional
delays in the
values. A value of 0 means that
'tustin' and 'matched' methods. Takes integer
c2d rounds fractional delays to
the nearest integer multiple of the sample time.
Default: 0
For additional information about the options and how to use them, see
“Converting Between Continuous- and Discrete-Time Representations”
in the Control System Toolbox User’s Guide and the
c2d reference page.
2-49
c2dOptions
ExamplesDiscretize two models using identical discretization options.
% generate two arbitrary continuous-t ime state-space models
sys1 = rss(3, 2, 2);
sys2 = rss(4, 4, 1);
Use c2dOp tion s to create a set of discretization options.
Then, discretize both models using the option set.
dsys1 = c2d(sys1, 0.1, op t);% 0.1s sampling time
dsys2 = c2d(sys2, 0.2, opt );% 0.2s sampling time
The c2dOptions option set does not include the sampling time Ts.You
can use the same discretization options to discretize systems using a
different sampling time.
References[1] Franklin, G.F., Powell, D.J., and Workman, M.L., Digital Control of
Dynamic Systems (3rd Edition), Prentice Hall, 1997.
Descriptioncanon computes a canonical state-space m odel for the continuo us or
discrete LTI system
Modal Form
csys = canon(sys,'modal') returns a realization csys in modal form.
If A has no repeated eigenvalues, the real eigenvalues appear on the
diagonal of the A matrix and the complex conjugate eigenvalues appear
in 2-by-2 block s on the diagonal of A. For a system with eigenvalues
(,, )
± j
12
000
⎡
1
⎢
00
⎢
⎢
00
−
⎢
000
⎣
sys. Two types of canonical forms are supported.
,themodalA matrix is of the form
⎤
⎥
⎥
⎥
⎥
2
⎦
canon
csys = canon(sys,'modal',CONDT) specifies an upper bound CONDT
on the condition number of the block-diagonalizing transformation T.
The default value is
eigenvalue clusters (setting
CONDT=1e8. Increase CONDT to reduce the size of the
CONDT=Inf amounts to diagonalizing A).
Companion Form
csys = canon(sys,'companion') produces a companion realization
of
sys where the characteristic polynomial of the system appears
explicitly in the rightmost column of the A matrix. For a system with
characteristic polynomial
pssss
nn
()=+ +++
−
1
1
…
nn
−
1
2-51
canon
the corresponding companion A matrix is
000
⎡
⎢
⎢
⎢
A
=
⎢⎢
⎢
⎢
⎢
⎣
.. ..
10001
010
:::
010
001
0
..
..
.. ..
..
.
−
⎤
n
−−
::
⎥
n
⎥
⎥
⎥
⎥
⎥
−
2
⎥
−
1
⎦
For state-space models sys,
[csys,T] = canon(sys,'type’)
also returns the state coordinate transformation T relating the original
state vector x and the canonical state vector x
xTx
=
c
,where
c
This syntax is meaningful only when sys is a state-space model.
AlgorithmTransfer functions or zero-pole-gain models are first conv erted to state
space using
The transformation to modal form uses the matrix P of eigenvectors of
the A matrix. The modal form is then obtained as
ss.
2-52
−−11
xPAPxPBu
=+
cc
yCPx Du
=+
c
The state transformation T returned is the inverse of P.
The reduction to companion form uses a state similarity transformation
based on the controllability matrix [1].
canon
LimitationsThe companion transformation requir es that the system be controllable
from the first input. The companion form is often p oo rly conditioned for
most state-space computations; avoid using it when possible.
References[1] Kailath, T. Linear Systems, Prentice-Hall, 1980.
See Alsoctrb, ctrbf, ss2ss
2-53
care
PurposeSolve continuous-time algebraic Ricca ti equation
Description[X,L,G] = care(A,B,Q) computes the unique solution X of the
continuous-time algebraic Riccati equation
TT
A XXAXBB XQ
+− +=0
GRBXE
The care function also returns the gain matrix,
[X,L,G] = care(A,B,Q,R,S,E) solves the more general Riccati
equation
=
−1
T
.
TT TTT
A XEE XAE XB S RB XESQ
+− +++=
()( )10
−
When omitted, R, S,andE are set to the default va lues R=I, S=0,
and
E=I. Along with the solution X, care returns the gain matrix
TT
−1
GR BXES
=+
()
L=eig(A-B*G,E)
[X,L,G,report] = care(A,B,Q,...)
• -
1 when the associated Hamiltonian pencil has eigenvalues on or
and a vector L of closed-loop eigenvalues, where
returns a diagnosis report with:
very near the imaginary axis (failure)
• -
2 whenthereisnofinitestabilizingsolutionX
• The Frobenius norm of the relative residual if X exists and is finite.
This syntax does not issue any error message when X fails to exist.
[X1,X2,D,L] = care(A,B,Q,...,'factor') returns two matrices X1,
X2 and a diagonal scaling matrix D such that X = D*(X2/X1)*D.
2-54
The vector L contains the closed-loop eigenvalues. All outputs are
empty when the associated Hamiltonian matrix has eigenvalues on
the imaginary axis.
ExamplesExample 1
Given
−
32
⎡
ABCR=
⎢
11
⎣
you can solve the Riccati equation
TTT
A XXAXBR B XC C
+−+ =−10
by
a = [-3 2;1 1]
b=[0;1]
c = [1 -1]
r=3
[x,l,g] = care(a,b,c'*c,r)
care
0
⎡
⎤
⎥
⎦
⎤
=
⎢
⎥
1
⎣
⎦
=−
113
[]
=
This yields the solution
x
x=
0.58951.8216
1.82168.8188
You can verify that this solution is indeed stabilizing by comparing
the eigenvalues of
[eig(a)eig(a-b*g)]
ans =
-3.4495-3.5026
a and a-b*g.
2-55
care
1.4495-1.4370
Finally, note that the variable l contains the closed-loop eigenvalues
eig(a-b*g).
l
l=
-3.5026
-1.4370
Example 2
-like Riccati equation
To solve the
H
∞
TTTT
AX XA XBB BB X CC
++−+ =
−
2
()γ
1122
0
rewrite it in the care format as
1
−
T
AX XA XBB
+−
[, ]
12
B
2
⎡
I
−
γ
⎢
0
⎢
⎣
R
0
I
T
⎡
B
1
⎢
T
⎢
B
⎣
2
⎤
⎥
⎥
⎦
T
XXCC
+=0
⎤
⎥
⎥
⎦
You can now compute the stabilizing solutionXby
B = [B1 , B2]
m1 = size(B1,2)
m2 = size(B2,2)
R = [-g^2*eye(m1) zeros(m1,m2) ; zero s(m2 ,m1) eye(m2)]
X = care(A,B,C'*C,R)
Algorithmcare implements the algorithms described in [1]. It works with the
EI=
Hamiltonian matrix when R is well-conditioned and
uses the extended Hamiltonian pencil and QZ algorithm.
;otherwiseit
2-56
care
LimitationsThe
(,)AB
controllable). In addition, the associated Hamiltonian matrix or pencil
must have no eigenvalue on the imaginary axis. Sufficient conditions
for this to hold are
⎡
⎢
SR
⎢
⎣
pair must be stabilizable (that is, all unstable modes are
QS
⎤
⎥
T
⎥
⎦
> 0
(, )QA
detectable when
S = 0
and
R > 0
,or
References[1] Arnold, W.F., III and A.J. Laub, "Generalized Eigenproblem
Algorithms and Software for Algebraic Riccati Equations," Proc. IEEE,
72 (1984), pp. 1746-1754
See Alsodare, lyap
2-57
chgunits
PurposeChange frequency units of FRD model
Syntaxsys = chgunits(sys,units)
Descriptionsys = chgunits(sys,units) converts the units of the frequency
points stored in an FRD model,
of the strings
frequencies by applying the appropriate (
'Units' property is updated.
'Units' field already matches units, no conversion is made.
If the
'Hz' or 'rad/s'. This operation changes the ass igned
Examplew = logspace(1,2,2);
sys = rss(3,1,1);
sys = frd(sys,w)
From input 'input 1' to:
Frequency(rad/s)output 1
-----------------------100.293773+0.00 1033i
1000.294404+0.000 109i
Continuous-time frequency response data.
sys = chgunits(sys,'Hz')
sys.freq
ans =
1.5915
15.9155
sys to units,whereunits is either
2*pi) scaling factor, and the
See Alsofrd, get, set
2-58
PurposeForm model with complex conjugate coefficients
Syntaxsysc = conj(sys)
Descriptionsysc = conj(sys) constructs a complex conjugate model sysc by
applying complex conjugation to all coefficients of the LTI model
sys. This function accepts LTI models in transfer function (TF),
zero/pole/gain (ZPK), and s tate space (SS) formats.
ExampleIf sys is the transfer function
(2+i)/(s+i)
then conj(sys) produces the transfer function
(2-i)/(s-i)
This operation is useful for manipulating partial fraction expansions.
conj
See Alsoappend, ss, tf, zpk
2-59
connect
PurposeArbitrary interconnection of LTI models
Syntaxsys = connect(sys1,sys2,...,inputs,outputs)
sys = connect(blksys,Q,inputs,outputs)
Descriptionconnect constructs the aggregate model for a given block diagram
interconnection of LTI models. You can specify the block diagram
connectivity in two ways:
• Name-based interconnection
• Index-based interconnection
Name-Based Interconnection
In this approach, you name the input and output signals of all LTI
blocks
blocks. The aggregate model
sys1, sys2,... in the block diagram, including the summation
sys is then built by
2-60
sys = connect(sys1,sys2,...,inputs,outputs)
where inputs and outputs are the names of the block diagram external
I/Os, specified as strings or cell arrays of strings.
Note For MIMO systems, you can use strseq to quickly generate
numbered channel names as a sequence of indexed strings, for example
{'e1','e2','e3'}.
Example of Name-Based Interconnection
Given LTI models C and G in the following block diagram,
connect
construct the closed-loop model T from r to y.
C.InputName = 'e';C .Out putName = 'u';
G.InputName = 'u';G. Outp utName = 'y';
Sum = sumblk('e','r','y','+-');
T = connect(G,C,Sum,'r','y')
Index-Based Interconnection
In this approach, first combine all LTI blocks into an aggregate,
unconnected model
where each row specifies one of the connections or summing junctions in
terms of the input vector
the row
blksys using append. Then, construct a matrix Q
u and output vector y of blksys. For example,
[3 2 0 0]
indicates that y(2) feeds into u(3), while the row
[7 2 -15 6]
indicates that y(2)-y(15)+y(6) feeds into u(7). The aggregate model
sys is then obtained by
sys = connect(blksys,Q,inputs,outputs)
where inputs and outputs are index vectors into u and y selecting
the block diagram external I/Os.
2-61
connect
Example of Index-Based Interconnection
Construct the closed-loop model T for the previous block diagram.
blksys = append(C,G);
% u = inputs to C,G.y = outputs of C,G.
% Here y(1) feeds into u(2) and -y(2) feeds into u(1)
Q = [2 1; 1 -2];
% External I/Os: r drives u(1) and y is y(2)
T = connect(blksys,Q,1,2)
Verify that you entered all of the model information correctly by
checking the following items:
• Poles of the unconnected model
blocks in the diagram.
• Final poles and DC gains are reasonable.
• Plots of the
step and bode responses of sysc are as expected.
sys match the poles of the various
Delays
The connect function supports I/O and internal delays. See Time
Delays for more information and examples.
ExampleConstruct the model shown in thefollowingblockdiagram.
2-62
connect
.
Use the matrices of the following state-space model
A = [ -9.0201 17.7791
-1.6943 3.2138 ];
B = [ -.5112 .5362
-.002 -1.8470];
C = [ -3.2897 2.4544
-13.5009 18.0745];
D = [-.5476 -.1410
-.6459 .2958 ];
1 Define the three blocks in the block diagram as individual LTI models
Note Blocks and states that are not connected to inputs or outputs are
automatically discarded.
References[1] Edwards, J.W., "A Fortran Program for the Analysis of Linear
Continuous and Sampled-Data Systems," NASA Report TM X56038,
Dryden Research C enter, 1976.
See Alsosumblk, strseq, append, feedback, minreal, parallel, ser ies, lft
2-66
PurposeOutput and state covariance of system driven by white noise
SyntaxP = covar(sys,W)
[P,Q] = covar(sys,W)
Descriptioncovar calculates the stationary covariance of the output y of an LTI
model
handles both continuous- and dis crete-time cases.
P = covar(sys,W) returns the steady-state output response covariance
sys driven by Gaussian white noise inputs w. This function
covar
PEyy
=()
given the noise intensity
EwtwW t
(()())()
EwkwlW
[P,Q] = covar(sys,W) als o returns the steady-state state covariance
QExx
=()
when sys is a state-space model (otherwise Q is set to []).
When applied to an
multidimensional arrays P, Q such that
P(:,:,i1,...iN) and Q(:,:,i1,...iN) are the covariance matrices
for the model
T
T
=−
()
[] []
T
=
kl
T
N-dimensional LTI array sys, covar returns
sys(:,:,i1,...iN).
(continuous time)
(disccrete time)
ExampleCompute the output response covariance of the discrete SISO system
21
z
Hz
()
+
2
0205
zz
++
..
,.=
01
T
=
s
duetoGaussianwhitenoiseofintensityW=5.Type
2-67
covar
sys = tf([2 1],[1 0.2 0.5],0.1);
p = covar(sys,5)
These commands produce the following result.
p=
30.3167
You can compare this output of covar to simulation results.
randn('seed',0)
w = sqrt(5)*randn(1,1000);% 1000 samples
% Simulate response to w with LSIM:
y = lsim(sys,w);
% Compute covariance of y values
psim = sum(y .* y)/length(w);
This yields
psim =
32.6269
The tw o covariance values p and psim do not agree perfectly due to the
finite simulation horizon.
AlgorithmTransfer functions and zero-pole-gain models are first converted to
2-68
state space with
For continuous-time state-space models
xAxBw
=+
yCxDw
=+
Q is obtained by solving the Lyapunov equation
ss.
covar
AQ QABWB
The output response covariance P is finite only when D = 0 and then
P = CQC
In discrete time, the state covariance solves the discrete Lyapunov
equation
AQAQBWB
and P is given by P = CQCT+ DWD
Note that P is well defined for nonzero D in the discrete case.
TT
++ =0
T
.
TT
−+=0
T
LimitationsThe state and output covariances are defined for stable systems only.
For continuous systems, the output response covariance P is finite only
when the D matrix is zero (strictly proper system).
References[1] Bryson, A.E. and Y.C. Ho, Applied O ptimal Control, Hemisphere
Publishing, 1975, pp. 458-459.
See Alsodlyap, lyap
2-69
ctrb
PurposeControllability matrix
SyntaxCo = ctrb(sys)
Descriptionctrb computes the controllability matrix for state-space systems. For
an n-by-n matrix
controllability matrix
⎡
Co BABABA B
=
⎣
where Co has n rows and nm columns.
Co = ctrb(sys) calcu l ates the controllability matrix of the state-space
LTI object
Co = ctrb(sys.A,sys.B)
The system is controllable if Co has full rank n.
sys. Thissyntaxisequivalenttoexecuting
A and an n-by-m matrix B, ctrb( A,B) returns the
n
−21
…
⎤
⎦
(2-1)
ExampleCheck if the system with the following data
A=
11
4-2
B=
1-1
1-1
is controllable. Type
Co=ctrb(A,B);
% Number of uncontrollable states
unco=length(A)-rank(Co)
These commands produce the following result.
2-70
unco =
1
LimitationsEstimating the rank of the controllability matrix is ill-conditioned; that
is, it is very sensitive to roundoff errors and errors in the data. An
indication of this can be seen from this simple example.
1
⎡
⎢
01
⎣
⎤
,
⎥
⎦
⎡
=
⎢
⎣
AB=
This pair is controllable if
relative machine precision.
BAB
[]
which is not full rank. For cases like these, it is better to determine the
controllability of a system using
=
11
1
⎡
⎤
⎢
⎥
⎣
⎦
≠ 0
but if
ctrb(A,B) returns
⎤
⎥
⎦
ctrbf.
< eps
,whereeps is the
ctrb
See Alsoctrbf, obsv
2-71
ctrbf
PurposeCompute controllability staircase form
Syntax[Abar,Bbar,Cbar,T,k] = ctrbf(A,B,C)
ctrbf(A,B,C,tol)
DescriptionIf the controllability matrix of (A , B)hasrankr ≤ n,wheren is the size
of A, then there exists a similarity transformation such that
ATAT BTBCCT
TT
===,,
where T is unitary, and the transformed system has a staircase form,
in which the uncontrollable modes, if there are any, are in the upper
left corner.
A
⎡
A
=
⎢
⎣
00
uc
AA
21
⎤
,,
⎥
cc
⎦
⎡
⎤
=
B
⎢
B
⎣
=
CCC
⎥
⎦
[]
nc c
where (Ac, Bc) is controllable, all eigenvalues of Aucare uncontrollable,
CsI A B CsI A B
and
[Abar,Bbar,Cbar,T,k] = ctrbf(A,B,C) decomposes the state-space
() ()−=−
ccc
system represented by
form,
Abar, Bbar,andCbar, described above. T is the similarity
transformation matrix and
of the system represented by
−−11
A, B,andC into the controllability staircase
k is a vector of length n,wheren is the order
.
A.Eachentryofk repres ents the number
of controllable states factored out during each step of the transformation
matrix calculation. The number of nonzero elements in
how many iterations were necessary to calculate
number of states in A
ctrbf(A,B,C,tol) uses the tolerance tol when calculating the
, the controllable portion of Abar.
c
T,andsum(k) is the
k indicates
controllable/uncontrollable subspaces. When the tolerance is not
specified, it defaults to
10*n*norm(A,1)*eps.
ExampleCompute the controllability staircase form for
A=
2-72
11
4-2
B=
1-1
1-1
C=
10
01
and locate the uncontrollable mode.
[Abar,Bbar,Cbar,T,k]=ctrbf(A,B,C)
Abar =
-3.00000
-3.00002.0000
Bbar =
0.00000.0000
1.4142-1.4142
ctrbf
Cbar =
-0.70710.7071
0.70710.7071
T=
-0.70710.7071
0.70710.7071
k=
10
The decomposed system Abar shows an uncontrollable mode located at
-3 and a controllable mode located at 2.
Algorithmctrbf implements the Staircase Algorithm of [1].
2-73
ctrbf
References[1] Ros enbrock, M.M., State-Space and Multivariable Theory,John
Wiley, 1970.
See Alsoctrb, minreal
2-74
ctrlpref
PurposeSet Control System Toolbox preferences
Syntaxctrlpref
Descriptionctrlpref opens a Graphical User Interface (GUI) which allows you to
change the Control System Toolbox preferences. Preferences set in this
GUI affect future plots only (existing plots are not altered).
Your preferences are stored to disk (in a system-dependent location)
and will be automatically reloaded in future MATLAB
the Control System Toolbox software.
See Alsosisotool, ltiview
®
sessions using
2-75
d2c
PurposeConvert from discrete- to continuous-time models
Syntaxsysc = d2c(sysd)
sysc = d2c(sysd,'method')
sysc = d2c(sysd, opts)
Descriptionsysc = d2c(sysd) produces a continuous-time model sysc that is
equivalent to the discrete-time LTI model
the inputs.
sysc = d2c(sysd,'method') uses the specified conversion method
'method':
sysd using zero-order hold on
'zoh'
'tustin'
'matched'
sysc = d2c(sysd, opts) converts sysd using the option set specified
with
d2cOptions object.
See “Converting Between Continuous- and Discrete-Time
Representations” for more details on the conversion methods.
Usage• Use the
the de
uency prewarp (formerly the
afreq
x
synta
and “Converting Between Continuous- and Discrete-Time
page
esentations” in the C ontrol System Toolbox User’s Guide.
Repr
Zero-order hold on the inputs. The control inputs are
assumed piecewise constant over the sampling period.
Bilinear (Tustin) approximation to the derivative.
Zero-pole matching method of [1] (for SISO systems only).
syntax
fault options for
sysc = d2c(sysd, opts).Seethed2cOptions reference
sysc = d2c(sysd, 'method') to convert sysd using
'method'.Tospecifytustin conversion with
'prewarp' method), use the
2-76
ExampleConsider the discrete-time model with transfer function
z
Hz
=
()
and sample time Ts= 0.1 s. You can derive a continuous-time
zero-order-hold equivalent model by typing
Hc = d2c(H)
Discretizing the resulting model Hc with the default zero-order hold
method and sampling time TH(z):
c2d(Hc,0.1)
To use the Tustin approximation i ns te ad of zero-order hold, type
Hc = d2c(H,'tustin')
−
zz
++1032.
= 0.1s returns the original discrete model
s
d2c
As with zero-order hold, the inverse discretization operation
c2d(Hc,0.1,'tustin')
gives back the original H(z).
Algorithmd2c performs the 'zoh' conversion in state space, and relies on the
matrix logarithm (see
logm in the MATLAB documentation).
LimitationsThe Tustin approximation is not defined for systems with poles at z =–1
and is ill-conditioned for systems with poles near z =–1.
The zero-order hold method cannot handle systems with poles at z =0.
In addition, the
with negative real poles , [2]. The model order increases because the
matrix logarithm maps real negative poles to complex p ole s. Single
complex poles are not physically meaningful because of their complex
time response.
'zoh' conversion increases the model order for systems
2-77
d2c
Instead, to ensure that all complex poles of the continuous model
come in conjugate pairs,
d2c replaces negative real poles z =–α with
a pair of complex conjugate poles near –α. The conversion then yields
a continuous model with higher order. For example, to convert the
discrete-time transfer function
02
.
z
Hz
()
=
zzz
()
+
2
0504
+
++
..
()
type:
Ts = 0.1% sample time 0.1 s
H = zpk(-0.2,-0.5,1,Ts) * tf(1,[1 1 0.4],Ts)
Hc = d2c(H)
These commands produce the following result.
Warning: System order was increased to handle real negative poles.
2-78
Zero/pole/gain:
-33.6556 (s-6.273) (s^2 + 28.29s + 1041)
--------------------------------------------
(s^2 + 9.163s + 637.3) (s^2 + 13.86s + 1035)
To convert Hc back to discrete time, type:
c2d(Hc,Ts)
yielding
Zero/pole/gain:
(z+0.5) (z+0.2)
------------------------(z+0.5)^2 (z^2 + z + 0.4)
Sampling time: 0.1
Loading...
+ hidden pages
You need points to download manuals.
1 point = 1 manual.
You can buy points or you can get point for every manual you upload.