Control System Toolbox™ Reference
Control System Toolbox™ Reference
Reference
R2014a
Web
Newsgroup
www.mathworks.com/contact_TS.html Technical Support
www.mathworks.com
comp.soft-sys.matlab
suggest@mathworks.com
bugs@mathworks.com
doc@mathworks.com
service@mathworks.com
info@mathworks.com
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 Reference
COPYRIGHT 20012014 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 MathWorks, 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
the use, modification, reproduction, release, performance, display, and disclosure of the Program and
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
governments needs or is inconsistent in any respect with federal procurement law, the government agrees
to return the Program and Documentation, 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
MathWorks products are protected by one or more U.S. patents. Please see
www.mathworks.com/patents for more information.
Revision History
June 2001
July 2002
June 2004
March 2005
September 2005
March 2006
September 2006
March 2007
September 2007
March 2008
October 2008
March 2009
September 2009
March 2010
September 2010
April 2011
September 2011
March 2012
September 2012
March 2013
September 2013
March 2014
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
Online
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
only
Contents
Functions Alphabetical List
1
Block Reference
vi
Contents
1
Functions Alphabetical
List
abs
1-2
Purpose
Syntax
absfrd = abs(sys)
Description
See Also
absorbDelay
Purpose
Syntax
sysnd = absorbDelay(sysd)
[sysnd,G] = absorbDelay(sysd)
Description
system model sysd into the system dynamics or the frequency response
data.
For discrete-time models (other than frequency response data models),
a delay of k sampling periods is replaced by k poles at z = 0. For
continuous-time models (other than frequency response data models),
time delays have no exact representation with a finite number of poles
and zeros. Therefore, use pade to compute a rational approximation of
the time delay.
For frequency response data models in both continuous and discrete
time, absorbDelay absorbs all time delays into the frequency response
data as a phase shift.
[sysnd,G] = absorbDelay(sysd) returns the matrix G that maps the
initial states of the ss model sysd to the initial states of the sysnd.
Examples
Example 1
Create a discrete-time transfer function that has a time delay and
absorb the time delay into the system dynamics as poles at z = 0.
z = tf('z',-1);
sysd = (-.4*z -.1)/(z^2 + 1.05*z + .08);
sysd.InputDelay = 3
1-3
absorbDelay
The display of sysnd shows that the factor of z^(-3) has been absorbed
as additional poles in the denominator.
Transfer function:
-0.4 z - 0.1
------------------------z^5 + 1.05 z^4 + 0.08 z^3
Sampling time: unspecified
Example 2
Convert "nk" into regular coefficients of a polynomial model.
Consider the discrete-time polynomial model:
m = idpoly(1,[0 0 0 2 3]);
The value of the B polynomial, m.b, has 3 leading zeros. Two of these
zeros are treated as input-output delays. Consequently:
sys = tf(m)
1-4
absorbDelay
See Also
1-5
allmargin
Purpose
Syntax
S = allmargin(sys)
S = allmargin(mag,phase,w,ts)
Description
S = allmargin(sys)
allmargin computes the gain margin, phase margin, delay margin
1-6
allmargin
See Also
ltiview | margin
1-7
append
Purpose
Syntax
sys = append(sys1,sys2,...,sysN)
Description
sys = append(sys1,sys2,...,sysN)
append appends the inputs and outputs of the models sys1,...,sysN to
form the augmented model sys depicted below.
0
H1 (s)
0
H
(
s
)
0 H N (s)
0
For state-space models sys1 and sys2 with data (A1, B1, C1, D1) and
(A2, B2, C2, D2), append(sys1,sys2) produces the following state-space
model:
1-8
append
x1 A1 0 x1 B1
x = 0 A x + 0
2
2 2
y1 C1 0 x1 D1
y = 0 C x + 0
2
2 2
Arguments
0 u1
B2 u2
0 u1
D2 u2
The input arguments sys1,..., sysN can be model objects s of any type.
Regular matrices are also accepted as a representation of static gains,
but there should be at least one model in the input list. The 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 Rules That Determine Model
Type for details).
There is no limitation on the number of inputs.
Examples
The commands
sys1 = tf(1,[1 0]);
sys2 = ss(1,2,3,4);
sys = append(sys1,10,sys2)
x1
0
0
x2
0
1
x1
x2
u1
1
0
u2
0
0
y1
x1
1
x2
0
b =
u3
0
2
c =
1-9
append
y2
y3
0
0
0
3
y1
y2
y3
u1
0
0
0
u2
0
10
0
d =
u3
0
0
4
Continuous-time model.
See Also
1-10
augstate
Purpose
Syntax
asys = augstate(sys)
Description
asys = augstate(sys)
x = Ax + Bu
y = Cx + Du
(or their discrete-time counterpart), augstate appends the states x to
the outputs y to form the model
x = Ax + Bu
y C
D
x = I x + 0 u
This command prepares the plant so that you can use the feedback
command to close the loop on a full-state feedback u = Kx.
Limitation
See Also
1-11
balreal
Purpose
Syntax
[sysb, g] = balreal(sys)
[sysb, g] =
balreal(sys,'AbsTol',ATOL,'RelTol',RTOL,'Offset',ALPHA)
[sysb, g] = balreal(sys, condmax)
[sysb, g, T, Ti] = balreal(sys)
Description
1-12
balreal
Examples
Example 1
Consider 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)
0.0001
0.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')
1-13
balreal
zpk(sysr)
Zero/pole/gain:
1.0001
-------(s+4.97)
1-14
balreal
Example 2
Create this unstable system:
sys1=tf(1,[1 0 -1])
Transfer function:
1
------s^2 - 1
x1
1
0
x2
0
-1
x1
x2
u1
0.7071
0.7071
b =
c =
y1
x1
0.7071
x2
-0.7071
d =
y1
u1
0
Continuous-time model.
1-15
balreal
g =
Inf
0.2500
Algorithms
x = Ax + Bu
y = Cx + Du
with controllability and observability gramians Wc and Wo. The state
coordinate transformation x = Tx produces the equivalent model
x = TAT 1 x + TBu
y = CT 1 x + Du
and transforms the gramians to
Wc = TWcT T , Wo = T T Wo T 1
The function balreal computes a particular similarity transformation
T such that
Wc = Wo = diag( g)
See [1], [2] for details on the algorithm.
References
1-16
[1] Laub, A.J., M.T. Heath, C.C. Paige, and R.C. Ward, "Computation
of System Balancing Transformations and Other Applications of
Simultaneous Diagonalization Algorithms," IEEE Trans. Automatic
Control, AC-32 (1987), pp. 115-122.
balreal
See Also
1-17
balred
Purpose
Syntax
rsys = balred(sys,ORDERS)
rsys = balred(sys,ORDERS,BALDATA)
rsys = balred( ___ ,opts)
Description
1-18
balred
References
See Also
Related
Examples
Concepts
1-19
balredOptions
Purpose
Syntax
opts = balredOptions
opts = balredOptions('OptionName', OptionValue)
Description
opts = balredOptions returns the default option set for the balred
command.
opts = balredOptions('OptionName', OptionValue) accepts one or
more comma-separated name/value pairs. Specify OptionName inside
single quotes.
Input
Arguments
'Truncate'
Default: 'MatchDC'
AbsTol, RelTol
1-20
balredOptions
Examples
G ( s) =
( s + 0 .5 ) ( s + 1 .1 ) ( s + 2 .9 )
.
( s + 106 ) ( s + 1) ( s + 2) ( s + 3)
Use the Offset option to exclude the pole at s = 106 from the stable
term of the stable/unstable decomposition.
sys = zpk([-.5 -1.1 -2.9],[-1e-6 -2 -1 -3],1);
% Create balredOptions
opt = balredOptions('Offset',.001,'StateElimMethod','Truncate');
% Compute second-order approximation
rsys = balred(sys,2,opt)
1-21
balredOptions
bode(sys,rsys)
See Also
1-22
balred | stabsep
bandwidth
Purpose
Syntax
fb = bandwidth(sys)
fb = bandwidth(sys,dbdrop)
Description
See Also
dcgain | issiso
1-23
bdschur
Purpose
Syntax
[T,B,BLKS] = bdschur(A,CONDMAX)
[T,B] = bdschur(A,[],BLKS)
Description
Input
Arguments
Output
Arguments
See Also
1-24
ordschur | schur
blkdiag
Purpose
Syntax
sys = blkdiag(sys1,sys2,...,sysN)
Description
0
..
0
sys1
0
sys2 .
:
:
.
.
0
0
..
0
sysN
Examples
The commands
sys1 = tf(1,[1 0]);
sys2 = ss(1,2,3,4);
sys = blkdiag(sys1,10,sys2)
x1
0
0
x2
0
1
x1
x2
u1
1
0
u2
0
0
y1
y2
y3
x1
1
0
0
x2
0
0
3
b =
u3
0
2
c =
1-25
blkdiag
d =
y1
y2
y3
u1
0
0
0
u2
0
10
0
u3
0
0
4
Continuous-time model.
See Also
1-26
bode
Purpose
Syntax
bode(sys)
bode(sys1,...,sysN)
bode(sys1,PlotStyle1,...,sysN,PlotStyleN)
bode(...,w)
[mag,phase] = bode(sys,w)
[mag,phase,wout] = bode(sys)
[mag,phase,wout,sdmag,sdphase] = bode(sys)
Description
system dynamics.
1-27
bode
units and phase values phase in degrees. The response values in mag
and phase correspond to the frequencies specified by w as follows:
If w is a cell array {wmin,wmax}, [mag,phase] = bode(sys,w)
returns the system response at frequency values in the range
{wmin,wmax}.
If w is a vector of frequencies, [mag,phase] = bode(sys,w) returns
the system response at each of the frequencies specified in w.
[mag,phase,wout] = bode(sys) returns magnitudes, phase values,
and frequency values wout corresponding to bode(sys).
[mag,phase,wout,sdmag,sdphase] = bode(sys) additionally returns
the estimated standard deviation of the magnitude and phase values
when sys is an identified model and [] otherwise.
Input
Arguments
sys
1-28
bode
Line style, marker, and color of both the line and marker, specified as
a one-, two-, or three-part string enclosed in single quotes (' '). The
elements of the string can appear in any order. The string can specify
only the line style, the marker, or the color.
For more information about configuring the PlotStyle string,
see Specify Line Style, Color, and Markers in the MATLAB
documentation.
w
Output
Arguments
mag
1-29
bode
magdb = 20*log10(mag)
phase
Examples
H (s) =
1-30
s2 + 0.1s + 7.5
s4 + 0.12s3 + 9 s2
bode
bode automatically selects the plot range based on the system dynamics.
1-31
bode
of 0.1-10 rad/s.
Compare Bode Plots of Several Dynamic Systems
Compare the frequency response of a continuous-time system to an
equivalent discretized system on the same Bode plot.
1 Create continuous-time and discrete-time dynamic systems.
1-32
bode
bode(H,Hd)
The string 'r' specifies a solid red line for the response of H. The string
'b--' specifies a dashed blue line for the response of Hd.
1-33
bode
Because H is a SISO model, the first two dimensions of mag and phase
are both 1. The third dimension is the number of frequencies in wout.
Bode Plot of Identified Model
Compare the frequency response of a parametric model, identified
from input/output data, to a non-parametric model identified using
the same data.
1 Identify parametric and non-parametric models based on data.
1-34
bode
w = linspace(0,10*pi,128);
sys_np = spa(z2,[],w);
sys_p = tfest(z2,2);
spa and tfest require System Identification Toolbox software.
sys_np is a non-parametric identified model. sys_p is a parametric
identified model.
2 Create a Bode plot that includes both systems.
bode(sys_np,sys_p,w);
1-35
bode
standard deviation data for the magnitude and phase of the frequency
response.
load iddata2 z2;
sys_p = tfest(z2,2);
w = linspace(0,10*pi,128);
[mag,ph,w,sdmag,sdphase] = bode(sys_p,w);
tfest requires System Identification Toolbox software.
sys_p is an identified transfer function model.
sdmag and sdphase contain the standard deviation data for the
mag = squeeze(mag);
sdmag = squeeze(sdmag);
semilogx(w,mag,'b',w,mag+3*sdmag,'k:',w,mag-3*sdmag,'k:');
1-36
bode
Algorithms
system.
2 Evaluates the gain and phase of the frequency response based on the
zero, pole, and gain data for each input/output channel of the system.
a For continuous-time systems, bode evaluates the frequency
z e jTs ,
0 N
,
Ts
Alternatives
See Also
How To
1-37
bodemag
Purpose
Syntax
bodemag(sys)
bodemag(sys,{wmin,wmax})
bodemag(sys,w)
bodemag(sys1,sys2,...,sysN,w)
Description
dynamic system 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 wmin and wmax (in rad/TimeUnit, where TimeUnit is the time
units of the input dynamic system, specified in the TimeUnit property
of sys).
bodemag(sys,w) uses the user-supplied vector W of frequencies, in
rad/TimeUnit, at which the frequency response is to be evaluated.
bodemag(sys1,sys2,...,sysN,w) shows the frequency response
magnitude of several models sys1,sys2,...,sysN on a single plot. The
frequency vector w is optional. You can also specify a color, line style,
and marker for each model. For example:
bodemag(sys1,'r',sys2,'y--',sys3,'gx')
See Also
1-38
bode | ltiview
bodeoptions
Purpose
Syntax
P = bodeoptions
P = bodeoptions('cstprefs')
Description
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 with the
options you selected in the Control System Toolbox Preferences Editor.
For more information about the editor, see Toolbox Preferences Editor
in the Users Guide documentation.
Description
TickLabel
Grid
XlimMode, YlimMode
Limit modes
Xlim, Ylim
Axes limits
IOGrouping
InputLabels,
OutputLabels
InputVisible,
OutputVisible
1-39
bodeoptions
Option
Description
ConfidenceRegionNumberSD
Number of standard deviations to use to plotting the response
confidence region (identified models only).
Default: 1.
FreqUnits
1-40
bodeoptions
Option
Description
'cycles/week'
'cycles/month'
'cycles/year'
Default: 'rad/s'
You can also specify 'auto' which uses frequency units
rad/TimeUnit relative to system time units specified in the
TimeUnit property. For multiple systems with different time
units, the units of the first system are used.
FreqScale
Frequency scale
Specified as one of the following strings: 'linear' | 'log'
Default: 'log'
MagUnits
Magnitude units
Specified as one of the following strings: 'dB' | 'abs'
Default: 'dB'
MagScale
Magnitude scale
Specified as one of the following strings: 'linear' | 'log'
Default: 'linear'
MagVisible
MagLowerLimMode
MagLowerLim
PhaseUnits
Phase units
Specified as one of the following strings: 'deg' | 'rad'
Default: 'deg'
1-41
bodeoptions
Option
Description
PhaseVisible
PhaseWrapping
PhaseMatching
PhaseMatchingFreq
PhaseMatchingValue
Examples
In 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.
1-42
bodeoptions
See Also
1-43
bodeplot
Purpose
Syntax
h = bodeplot(sys)
bodeplot(sys)
bodeplot(sys1,sys2,...)
bodeplot(AX,...)
bodeplot(..., plotoptions)
bodeplot(sys,w)
Description
for a list of available plot options. See Example 2 on page 1-45 for
an example of phase matching using the PhaseMatchingFreq and
PhaseMatchingValue options.
bodeplot(sys,w) draws the Bode plot for frequencies specified by w.
When w = {wmin,wmax}, the Bode plot is drawn for frequencies between
wmin and wmax (in rad/TimeUnit, where TimeUnit is the time units of
1-44
bodeplot
Tips
You 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.
Examples
Example 1
Use the plot handle to change options in a Bode plot.
sys = rss(5);
h = bodeplot(sys);
% Change units to Hz and make phase plot invisible
setoptions(h,'FreqUnits','Hz','PhaseVisible','off');
Example 2
The properties PhaseMatchingFreq and PhaseMatchingValue are
parameters you can use to specify the phase at a specified frequency.
For example, enter the following commands.
sys = tf(1,[1 1]);
h = bodeplot(sys) % This displays a Bode plot.
1-45
bodeplot
1-46
bodeplot
The first bode plot has a phase of -45 degrees at a frequency of 1 rad/s.
Setting the phase matching options so that at 1 rad/s the phase is near
750 degrees yields the second Bode plot. Note that, however, the phase
can only be -45 + N*360, where N is an integer, and so the plot is set to
the nearest allowable phase, namely 675 degrees (or 2*360 - 45 = 675).
Example 3
Compare the frequency responses of identified state-space models of
order 2 and 6 along with their 2 std confidence regions.
load iddata1
sys1 = n4sid(z1, 2) % discrete-time IDSS model of order 2
sys2 = n4sid(z1, 6) % discrete-time IDSS model of order 6
Both models produce about 76% fit to data. However, sys2 shows
higher uncertainty in its frequency response, especially close to Nyquist
frequency as shown by the plot:
1-47
bodeplot
w = linspace(8,10*pi,256);
h = bodeplot(sys1,sys2,w);
setoptions(h, 'PhaseMatching', 'on', 'ConfidenceRegionNumberSD', 2);
Example 4
Compare the frequency response of a parametric model, identified
from input/output data, to a nonparametric model identified using
the same data.
1 Identify parametric and non-parametric models based on data.
identified model.
2 Create a Bode plot that includes both systems.
See Also
1-48
c2d
Purpose
Syntax
sysd = c2d(sys,Ts)
sysd = c2d(sys,Ts,method)
sysd = c2d(sys,Ts,opts)
[sysd,G] = c2d(sys,Ts,method)
[sysd,G] = c2d(sys,Ts,opts)
Description
model sys using zero-order hold on the inputs and a sample time of
Ts seconds.
sysd = c2d(sys,Ts,method) discretizes sys using the specified
Tips
Input
Arguments
sys
1-49
c2d
Sample time.
method
Output
Arguments
1-50
sysd
c2d
x0
x [ 0] = G
u0
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 Continuous-Discrete Conversion Methods for a discussion
of modeling time delays in discretized systems.
Examples
H ( s) =
s 1
2
s + 4s + 5
with input delay Td = 0.35 second. To discretize this system using the
triangle (first-order hold) approximation with sample time Ts = 0.1
second, type
H = tf([1 -1], [1 4 5], 'inputdelay', 0.35);
Hd = c2d(H, 0.1, 'foh'); % discretize with FOH method and
% 0.1 second sample time
1-51
c2d
Transfer function:
0.0115 z^3 + 0.0456 z^2 - 0.0562 z - 0.009104
--------------------------------------------z^6 - 1.629 z^5 + 0.6703 z^4
Sampling time: 0.1
1-52
c2d
H ( s ) = e0.25 s
10
2
s + 3s + 10
1-53
c2d
%
%
x1
-4
1
b =
u1
1-54
x2
-2
0
c2d
x1
x2
2
0
y1
x1
0.5
y1
u1
0
c =
x2
1
d =
x1
-0.4286
0.2857
0
0
0
x2
-0.5714
0.7143
0
0
0
x3
-0.00265
-0.001325
-0.2432
0.25
0
x4
0.06954
0.03477
0.1449
0
0.125
x5
2.286
1.143
-0.1153
0
0
b =
x1
x2
x3
x4
x5
u1
0.002058
0.001029
8
0
0
1-55
c2d
c =
y1
x1
0.2857
x2
0.7143
x3
-0.001325
x4
0.03477
x5
1.143
d =
y1
u1
0.001029
Sampling time: 1
Discrete-time model.
The discretized model now contains three additional states x3, x4,
and x5 corresponding to a third-order Thiran filter. Since the time
delay divided by the sampling time is 2.7, the third-order Thiran filter
(FractDelayApproxOrder = 3) can approximate the entire time delay.
Discretize an identified, continuous-time transfer function and compare
its performance against a directly estimated discrete-time model
Estimate a continuous-time transfer function and discretize it.
load iddata1
sys1c = tfest(z1, 2);
sys1d = c2d(sys1c, 0.1, 'zoh');
1-56
c2d
The Predictor is a two input model which uses the measured output
and input signals ([z1.y z1.u]) to compute the 1-steap predicted
response of sysc.
Algorithms
For information about the algorithms for each c2d conversion method,
see Continuous-Discrete Conversion Methods.
1-57
c2d
See Also
How To
1-58
c2dOptions
Purpose
Syntax
opts = c2dOptions
opts = c2dOptions('OptionName', OptionValue)
Description
Input
Arguments
'foh'
'impulse'
Impulse-invariant discretization.
'tustin'
'matched'
1-59
c2dOptions
Default: 'zoh'
PrewarpFrequency
Examples
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.
1-60
c2dOptions
References
[1] Franklin, G.F., Powell, D.J., and Workman, M.L., Digital Control of
Dynamic Systems (3rd Edition), Prentice Hall, 1997.
See Also
c2d
1-61
canon
Purpose
Syntax
csys = canon(sys,type)
[csys,T]= canon(sys,type)
csys = canon(sys,'modal',condt)
Description
Input
Arguments
sys
String specifying the type of canonical form of csys. type can take
one of the two following values:
'modal' convert sys to modal form.
'companion' convert sys to companion form.
condt
1-62
canon
Output
Arguments
csys
Definitions
Modal Form
In modal form, A is a block-diagonal matrix. The block size is typically
1-by-1 for real eigenvalues and 2-by-2 for complex eigenvalues.
However, if there are repeated eigenvalues or clusters of nearby
eigenvalues, the block size can be larger.
For example, for a system with eigenvalues (1 , j, 2 ) , the modal A
matrix is of the form
1
0
0
0
0 0 2
0
Companion Form
In the companion realization, the characteristic polynomial of the
system appears explicitly in the rightmost column of the A matrix. For
a system with characteristic polynomial
p(s) = sn + 1 sn 1 + + n 1 s + n
1-63
canon
0
1
0
A=
:
0
0 .. .. 0
n
0 0 .. 0 n 1
1 0 . :
:
0 . . :
:
2
. . 1 0
1
.. .. 0 1
Examples
This example uses canon to convert a system having doubled poles and
clusters of close poles to modal canonical form.
Consider the system G having the following transfer function:
G ( s ) = 100
( s 1) ( s + 1)
.
2
2
s ( s + 10 ) ( s + 10.0001) ( s (1 + i ) ) ( s (1 i ) )
1-64
canon
1.0000
1.0000
-1.0000
1.0000
2.0548
1.0000
1.0000
-1.0000
1.0000
-10.0000
8.0573
-10.0001
To separate the two poles near s = 10, you can increase the value of
condt. For example:
Gc2 = canon(G,'modal',1e10);
Gc2.A
ans =
0
1.0000
1.0000
-1.0000
1.0000
2.0548
1.0000
1.0000
-1.0000
1.0000
-10.0000
-10.0001
The A matrix of Gc2 includes separate diagonal elements for the poles
near s = 10. The cost of increasing the maximum condition number of
A is that the B matrix includes some large values.
format shortE
Gc2.B
ans =
3.2000e-001
-6.5691e-003
5.4046e-002
-1.9502e-001
1-65
canon
1.0637e+000
3.2533e+005
3.2533e+005
Algorithms
The canon command uses the bdschur command to convert sys into
modal form and to compute the transformation T. If sys is not a
state-space model, the algorithm first converts it to state space using ss.
The reduction to companion form uses a state similarity transformation
based on the controllability matrix [1].
1-66
References
See Also
care
Purpose
Syntax
[X,L,G] = care(A,B,Q)
[X,L,G] = care(A,B,Q,R,S,E)
[X,L,G,report] = care(A,B,Q,...)
[X1,X2,D,L] = care(A,B,Q,...,'factor')
Description
AT X + XA XBBT X + Q = 0
The care function also returns the gain matrix, G = R1 BT XE .
[X,L,G] = care(A,B,Q,R,S,E) solves the more general Riccati
equation
AT XE + ET XA ( ET XB + S) R1 ( BT XE + ST ) + Q = 0
When omitted, R, S, and E are set to the default values R=I, S=0,
and E=I. Along with the solution X, care returns the gain matrix
1-67
care
Examples
Example 1
Solve Algebraic Riccati Equation
Given
3 2
A=
1 1
0
B=
1
C = [1 1]
R=3
AT X + XA XBR1 BT X + C T C = 0
by
a = [-3 2;1 1]
b = [0 ; 1]
c = [1 -1]
r = 3
[x,l,g] = care(a,b,c'*c,r)
1.8216
8.8188
1-68
eig(a-b*g)]
care
ans =
-3.4495
1.4495
-3.5026
-1.4370
Example 2
Solve H-infinity ( H )-like Riccati Equation
To solve the H -like Riccati equation
AT X + XA + X ( 2 B1 B1T B2 B2T ) X + C T C = 0
rewrite it in the care format as
2 I 0
AT X + XA X [ B1 , B2 ]
0
I
B1T
X + CT C = 0
T
B2
1-69
care
Algorithms
Limitations
The ( A, B) pair must be stabilizable (that is, all unstable modes are
controllable). In addition, the associated Hamiltonian matrix or pencil
must have no eigenvalue on the imaginary axis. Sufficient conditions
for this to hold are (Q, A) detectable when S = 0 and R > 0 , or
Q
T
S
1-70
S
>0
R
References
See Also
dare | lyap
chgFreqUnit
Purpose
Syntax
sys_new = chgFreqUnit(sys,newfrequnits)
Description
Tips
Input
Arguments
sys
Default: 'rad/TimeUnit'
1-71
chgFreqUnit
Output
Arguments
sys_new
Examples
Frequency-response data model of the same type as sys with new units
of frequency points. The frequency response of sys_new is same as sys.
load AnalyzerData;
sys = frd(resp,freq);
The data file AnalyzerData has column vectors freq and resp.
These vectors contain 256 test frequencies and corresponding
complex-valued frequency response points, respectively. The default
frequency units of sys is rad/TimeUnit, where TimeUnit is the
system time units.
2 Change the frequency units.
sys1 = chgFreqUnit(sys,'rpm');
bode(sys,'r',sys1,'y--');
legend('sys','sys1')
1-72
chgFreqUnit
1-73
chgFreqUnit
See Also
chgTimeUnit | frd
Tutorials
1-74
chgTimeUnit
Purpose
Syntax
sys_new = chgTimeUnit(sys,newtimeunits)
Description
Tips
Input
Arguments
sys
1-75
chgTimeUnit
Output
Arguments
sys_new
Dynamic system model of the same type as sys with new time units.
The time response of sys_new is same as sys.
If sys is an identified linear model, both the model parameters as and
their minimum and maximum bounds are scaled to the new time units.
Examples
This example shows how to change the time units of a transfer function
model.
1 Create a transfer function model.
num = [4 2];
den = [1 3 10];
sys = tf(num,den);
sys1 = chgTimeUnit(sys,'minutes');
step(sys,'r',sys1,'y--');
legend('sys','sys1');
1-76
chgTimeUnit
1-77
chgTimeUnit
1-78
See Also
Tutorials
conj
Purpose
Syntax
sysc = conj(sys)
Description
Examples
See Also
append | ss | tf | zpk
1-79
connect
Purpose
Syntax
sysc = connect(sys1,...,sysN,inputs,outputs)
sysc = connect(blksys,connections,inputs,outputs)
sysc = connect( ___ ,opts)
Description
Input
Arguments
1-80
sys1,...,sysN
connect
inputs
1-81
connect
opts
Output
Arguments
sysc
Examples
1-82
connect
C =
C.u
G =
G.u
pid(2,1);
= 'e'; C.y = 'u';
zpk([],[-1,-1],1);
= 'u'; G.y = 'y';
When you specify single names for vector-valued signals, the software
automatically performs vector expansion of the signal names. For
example, examine the names of the inputs to C.
C.InputName
ans =
1-83
connect
'e(1)'
'e(2)'
The block diagram elements G, C, and Sum are all 2-input, 2-output
models. Therefore, connect performs the same vector expansion.
connect selects all entries of the two-input signals 'r' and 'y' as
inputs and outputs to T, respectively. For example, examine the input
names of T.
T.InputName
ans =
'r(1)'
'r(2)'
Index-Based Interconnection
Create an aggregate model of the following block diagram from r to y
using index-based interconnection.
1-84
connect
C = pid(2,1);
G = zpk([],[-1,-1],1);
blksys = append(C,G);
The first row indicates that w(1) connects to u(2); in other words, that
the output of C connects to the input of G. The second row indicates
that -w(2) connects to u(1); in other words, that the negative of the
output of G connects to the input of C.
Create the connected aggregate model from r to y.
T = connect(blksys,connections,1,2)
The last two arguments specify the external inputs and outputs in
terms of the indices of blksys. 1 specifies that the external input
connects to u(1). The last argument, 2, specifies that the external
output connects from w(2).
See Also
How To
1-85
connectOptions
Purpose
Syntax
opt = connectOptions
opt = connectOptions(Name,Value)
Description
Input
Arguments
1-86
connectOptions
Output
Arguments
Examples
See Also
connect
1-87
covar
Purpose
Syntax
P = covar(sys,W)
[P,Q] = covar(sys,W)
Description
P = E( yyT )
given the noise intensity
(disccrete time)
Q = E( xxT )
when sys is a state-space model (otherwise Q is set to []).
When applied to an N-dimensional LTI array sys, covar returns
multidimensional arrays P, Q such that
P(:,:,i1,...iN) and Q(:,:,i1,...iN) are the covariance matrices
for the model sys(:,:,i1,...iN).
Examples
H ( z) =
2z + 1
2
z + 0.2 z + 0.5
, Ts = 0.1
1-88
covar
% 1000 samples
This yields
psim =
32.6269
The two covariance values p and psim do not agree perfectly due to the
finite simulation horizon.
Algorithms
x Ax Bw
y Cx Dw,
the steady-state state covariance Q is obtained by solving the Lyapunov
equation
1-89
covar
AQ QAT BWBT 0.
In discrete time, the state covariance Q solves the discrete Lyapunov
equation
AQAT Q BWBT 0.
In both continuous and discrete time, the output response covariance is
given by P = CQCT + DWDT. For unstable systems, P and Q are infinite.
1-90
References
[1] Bryson, A.E. and Y.C. Ho, Applied Optimal Control, Hemisphere
Publishing, 1975, pp. 458-459.
See Also
dlyap | lyap
ctrb
Purpose
Controllability matrix
Syntax
Co = ctrb(sys)
Description
Co = B AB A2 B An 1 B
(1-1)
Examples
1
-2
1
1
-1
-1
B =
is controllable. Type
Co=ctrb(A,B);
% Number of uncontrollable states
unco=length(A)-rank(Co)
1-91
ctrb
unco =
1
Limitations
1
1
A=
, B=
0 1
This pair is controllable if 0 but if < eps , where eps is the
relative machine precision. ctrb(A,B) returns
[B
1 1
AB] =
which is not full rank. For cases like these, it is better to determine the
controllability of a system using ctrbf.
See Also
1-92
ctrbf | obsv
ctrbf
Purpose
Syntax
[Abar,Bbar,Cbar,T,k] = ctrbf(A,B,C)
ctrbf(A,B,C,tol)
Description
A = TAT T , B = TB, C = CT T
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 = uc
A21
0
0
, B = , C = [CncCc ]
Ac
Bc
Examples
1-93
ctrbf
1
4
1
-2
1
1
-1
-1
1
0
0
1
B =
C =
0
2.0000
Bbar =
0.0000
1.4142
0.0000
-1.4142
Cbar =
-0.7071
0.7071
0.7071
0.7071
T =
-0.7071
0.7071
0.7071
0.7071
k =
1
Algorithms
1-94
ctrbf
References
See Also
ctrb | minreal
1-95
ctrlpref
Purpose
Syntax
ctrlpref
Description
See Also
1-96
sisotool | ltiview
d2c
Purpose
Syntax
sysc = d2c(sysd)
sysc = d2c(sysd,method)
sysc = d2c(sysd,opts)
[sysc,G] = d2c(sysd,method,opts)
Description
Tips
Input
Arguments
sysd
1-97
d2c
Output
Arguments
sysc
Matrix mapping the states xd[k] of the state-space model sysd to the
states xc(t) of sysc:
x k
xc kTs G d .
u k
1-98
d2c
x
xc 0 G 0 .
u0
Examples
Example 1
Consider the discrete-time model with transfer function
H ( z) =
z 1
2
z + z + 0 .3
1-99
d2c
Example 2
Convert an identified transfer function and compare its performance
against a directly estimated continuous-time model.
load iddata1
sys1d = tfest(z1, 2, 'Ts', 0.1);
sys1c = d2c(sys1d, 'zoh');
sys2c = tfest(z1, 2);
compare(z1, sys1c, sys2c)
Example 3
Analyze the effect of parameter uncertainty on frequency response
across d2c operation on an identified model.
load iddata1
1-100
d2c
Algorithms
d2c performs the 'zoh' conversion in state space, and relies on the
matrix logarithm (see logm in the MATLAB documentation).
Limitations
1-101
d2c
H ( z) =
z + 0 .2
( z + 0.5 ) ( z2 + z + 0.4 )
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)
Zero/pole/gain:
-33.6556 (s-6.273) (s^2 + 28.29s + 1041)
-------------------------------------------(s^2 + 9.163s + 637.3) (s^2 + 13.86s + 1035)
yielding
Zero/pole/gain:
(z+0.5) (z+0.2)
------------------------(z+0.5)^2 (z^2 + z + 0.4)
Sampling time: 0.1
1-102
d2c
This discrete model coincides with H(z) after canceling the pole/zero
pair at z = 0.5.
References
See Also
1-103
d2cOptions
Purpose
Syntax
opts = d2cOptions
opts = d2cOptions(Name,Value)
Description
Input
Arguments
'foh'
'tustin'
'matched'
Default: 'zoh'
PrewarpFrequency
1-104
d2cOptions
Default: 0
For additional information about conversion methods, see
Continuous-Discrete Conversion Methods.
Examples
z+1
2
z + z+1
hd = tf([1 1], [1 1 1], 0.1);
You can use opts to resample additional models using the same options.
References
See Also
d2c
1-105
d2d
Purpose
Syntax
Description
Tips
Examples
Example 1
Consider the zero-pole-gain model
H ( z) =
z 0 .7
z 0 .5
with sample time 0.1 s. You can resample this model at 0.05 s by typing
H = zpk(0.7,0.5,1,0.1)
1-106
d2d
H2 = d2d(H,0.05)
Zero/pole/gain:
(z-0.8243)
---------(z-0.7071)
Sampling time: 0.05
Example 2
Suppose you estimates a discrete-time model of a sample time
commensurate with the estimation data (Ts = 0.1 seconds). However,
your deployment application demands a faster sampling frequency (Ts
= 0.01 seconds).
load iddata1
sys = oe(z1, [2 2 1]);
sysFast = d2d(sys, 0.01, 'zoh')
bode(sys, sysFast)
See Also
1-107
d2dOptions
Purpose
Syntax
opts = d2dOptions
opts = d2dOptions('OptionName', OptionValue)
Description
This table summarizes the options that the d2d command supports.
Input
Arguments
'tustin'
Default: 'zoh'
PrewarpFrequency
1-108
d2dOptions
Examples
z+1
2
z + z+1
h1 = tf([1 1], [1 1 1], 0.1);
You can use opts to resample additional models using the same options.
See Also
d2d
1-109
damp
Purpose
Syntax
damp(sys)
[Wn,zeta] = damp(sys)
[Wn,zeta,P] = damp(sys)
Description
Input
Arguments
sys
Output
Arguments
Wn
Vector containing the damping ratios of each pole of sys, in the same
order as Wn.
1-110
damp
Examples
H (s)
2s2 5s 1
s2 2s 3
-1.00e+00 + 1.41e+00i
-1.00e+00 - 1.41e+00i
Damping
Frequency
(rad/seconds)
Time Constant
(seconds)
5.77e-01
5.77e-01
1.73e+00
1.73e+00
1.00e+00
1.00e+00
1-111
damp
[Wn,zeta] = damp(H);
-3.02e-01 + 8.06e-01i
-3.02e-01 - 8.06e-01i
-5.40e+00
Magnitude
Damping
Frequency
(rad/seconds)
8.61e-01
8.61e-01
5.40e+00
7.74e-02
7.74e-02
-4.73e-01
1.93e+02
1.93e+02
3.57e+02
1-112
Time
(s
6
6
-5
damp
Algorithms
The natural frequency, time constant, and damping ratio of the system
poles are defined in the following table:
Continuous Time
Pole Location
Equivalent
Continuous-Time
Pole
Not applicable
ln( z)
Ts
Natural Frequency
n s
n s
ln( z)
Ts
Damping Ratio
cos(s)
1
n
Time Constant
See Also
1
n
1-113
dare
Purpose
Syntax
[X,L,G] = dare(A,B,Q,R)
[X,L,G] = dare(A,B,Q,R,S,E)
[X,L,G,report] = dare(A,B,Q,...)
[X1,X2,L,report] = dare(A,B,Q,...,'factor')
Description
AT XA X AT XB( BT XB + R)1 BT XA + Q = 0
The dare function also returns the gain matrix,
AT XA ET XE ( AT XB + S)( BT XB + R)1 ( BT XA + ST ) + Q = 0
or, equivalently, if R is nonsingular,
G = ( BT XB + R)1 ( BT XA + ST )
and a vector L of closed-loop eigenvalues, where
L= eig(A-B*G,E)
1-114
dare
with value:
-1 when the associated symplectic pencil has eigenvalues on or very
near the unit circle
-2 when there is no finite stabilizing solution X
The Frobenius norm if X exists and is finite
[X1,X2,L,report] = dare(A,B,Q,...,'factor') returns two
matrices, X1 and X2, and a diagonal scaling matrix D such that X
= D*(X2/X1)*D. The vector L contains the closed-loop eigenvalues.
All outputs are empty when the associated Symplectic matrix has
eigenvalues on the unit circle.
Algorithms
Limitations
Q S
T
>0
S R
References
See Also
1-115
db2mag
Purpose
Syntax
y = db2mag(ydb)
Description
See Also
1-116
mag2db
dcgain
Purpose
Syntax
k = dcgain(sys)
Description
Continuous Time
The continuous-time DC gain is the transfer function value at the
frequency s = 0. For state-space models with matrices (A, B, C, D),
this value is
K = D CA1B
Discrete Time
The discrete-time DC gain is the transfer function value at z = 1. For
state-space models with matrices (A, B, C, D), this value is
K = D + C (I A)1B
Tips
Examples
Example 1
To compute the DC gain of the MIMO transfer function
1
H ( s) =
1
s + 1
s 1
s + s + 3
s+2
s 3
2
type
H = [1 tf([1 -1],[1 1 3]) ; tf(1,[1 1]) tf([1 2],[1 -3])];
dcgain(H)
1-117
dcgain
ans =
1.0000
1.0000
-0.3333
-0.6667
Example 2
To compute the DC gain of an identified process model, type;
load iddata1
sys = idproc('p1d');
syse = procest(z1, sys)
dcgain(syse)
See Also
1-118
evalfr | norm
delay2z
Purpose
1-119
delayss
Purpose
Syntax
sys=delayss(A,B,C,D,delayterms)
sys=delayss(A,B,C,D,ts,delayterms)
Description
sys=delayss(A,B,C,D,delayterms)constructs a continuous-time
counterpart:
N
where Nj, j=1,..,N are time delays expressed as integer multiples of the
sampling period ts.
1-120
delayss
Examples
dx
= x(t ) x(t 1.2) + 2u (t 0.5)
dt
y (t ) = x(t 0.5) + u (t )
type
DelayT(1) = struct('delay',0.5,'a',0,'b',2,'c',1,'d',0);
DelayT(2) = struct('delay',1.2,'a',-1,'b',0,'c',0,'d',0);
sys = delayss(1,0,0,1,DelayT)
a =
x1
x1
0
x1
u1
2
y1
x1
1
y1
u1
1
b =
c =
d =
0.5
1.2
Continuous-time model.
See Also
getdelaymodel | ss
1-121
dlqr
Purpose
Syntax
[K,S,e] = dlqr(A,B,Q,R,N)
Description
u [ n] = Kx [ n]
minimizes the quadratic cost function
J (u) =
( x [ n]
n =1
Qx [ n] + u [ n] Ru [ n] + 2 x [ n] Nu [ n])
T
x [ n + 1] = Ax [ n] + Bu [ n]
The default value N=0 is assumed when N is omitted.
In addition to the state-feedback gain K, dlqr returns the infinite
horizon solution S of the associated discrete-time Riccati equation
AT SA S ( AT SB + N )( BT SB + R)1 ( BT SA + N T ) + Q = 0
and the closed-loop eigenvalues e = eig(A-B*K). Note that K is derived
from S by
K = ( BT SB + R)1 ( BT SA + N T )
Limitations
1-122
dlqr
See Also
1-123
dlyap
Purpose
Syntax
X = dlyap(A,Q)
X = dlyap(A,B,C)
X = dlyap(A,Q,[],E)
Description
X + Q = 0,
where A and Q are n-by-n matrices.
The solution X is symmetric when Q is symmetric, and positive definite
when Q is positive definite and A has all its eigenvalues inside the unit
disk.
X = dlyap(A,B,C) solves the Sylvester equation AXB X + C = 0,
Algorithms
Diagnostics
References
1-124
dlyap
[2] Bartels, R.H. and G.W. Stewart, "Solution of the Matrix Equation
AX + XB = C," Comm. of the ACM, Vol. 15, No. 9, 1972.
[3] Hammarling, S.J., Numerical solution of the stable, non-negative
definite Lyapunov equation, IMA J. Num. Anal., Vol. 2, pp. 303-325,
1982.
[4] Higham, N.J., FORTRAN codes for estimating the one-norm of
a real or complex matrix, with applications to condition estimation,
A.C.M. Trans. Math. Soft., Vol. 14, No. 4, pp. 381-396, 1988.
[5] Penzl, T., Numerical solution of generalized Lyapunov equations,
Advances in Comp. Math., Vol. 8, pp. 33-48, 1998.
[6] Golub, G.H., Nash, S. and Van Loan, C.F. A Hessenberg-Schur
method for the problem AX + XB = C, IEEE Trans. Auto. Contr.,
AC-24, pp. 909-913, 1979.
[7] Sima, V. C, Algorithms for Linear-quadratic Optimization, Marcel
Dekker, Inc., New York, 1996.
See Also
covar | lyap
1-125
dlyapchol
Purpose
Syntax
R = dlyapchol(A,B)
X = dlyapchol(A,B,E)
Description
All eigenvalues of A matrix must lie in the open unit disk for R to exist.
X = dlyapchol(A,B,E) computes a Cholesky factorization X = R'*R of
X solving the Sylvester equation
A*X*A' - E*X*E' + B*B' = 0
All generalized eigenvalues of (A,E) must lie in the open unit disk for R
to exist.
Algorithms
References
[1] Bartels, R.H. and G.W. Stewart, "Solution of the Matrix Equation
AX + XB = C," Comm. of the ACM, Vol. 15, No. 9, 1972.
[2] Hammarling, S.J., Numerical solution of the stable, non-negative
definite Lyapunov equation, IMA J. Num. Anal., Vol. 2, pp. 303-325,
1982.
[3] Penzl, T., Numerical solution of generalized Lyapunov equations,
Advances in Comp. Math., Vol. 8, pp. 33-48, 1998.
See Also
1-126
dlyap | lyapchol
drss
Purpose
Syntax
sys = drss(n)
drss(n,p)
drss(n,p,m)
drss(n,p,m,s1,...sn)
Description
sys = drss(n) generates an n-th order model with one input and one
output, and returns the model in the state-space object sys. The poles
of sys are random and stable with the possible exception of poles at
z = 1 (integrators).
drss(n,p) generates an n-th order model with one input and p outputs.
drss(n,p,m) generates an n-th order model with p outputs and m
inputs.
drss(n,p,m,s1,...sn) generates a s1-by-sn array of n-th order
models with m inputs and p outputs.
Examples
Generate a discrete LTI system with three states, four outputs, and
two inputs.
sys = drss(3,4,2)
a =
x1
x2
x3
x1
0.4766
0.1102
-0.7222
x2
0.1102
0.9115
0.1628
x1
x2
u1
-0.4326
-0
u2
0.2877
-0
x3
-0.7222
0.1628
-0.202
b =
1-127
drss
x3
1.191
c =
y1
y2
y3
y4
x1
1.189
-0.03763
0.3273
0.1746
x2
-0.1867
0.7258
-0.5883
2.183
y1
y2
y3
y4
u1
-0.09565
-0.8323
0.2944
-0
u2
0
1.624
-0.6918
0.858
d =
See Also
1-128
rss | tf | zpk
x3
-0
0.1139
1.067
0
dsort
Purpose
Syntax
dsort
[s,ndx] = dsort(p)
Description
When called with one lefthand argument, dsort returns the sorted
poles in s.
[s,ndx] = dsort(p) also returns the vector ndx containing the indices
Examples
Limitations
See Also
1-129
dss
Purpose
Syntax
sys = dss(A,B,C,D,E)
sys = dss(A,B,C,D,E,Ts)
sys = dss(A,B,C,D,E,ltisys)
Description
state-space model
dx
Ax Bu
dt
y Cx Du
The output sys is an SS model storing the model data (see State-Space
Models ). Note that ss produces the same type of object. If the matrix
D = 0, you can simply set d to the scalar 0 (zero).
sys = dss(A,B,C,D,E,Ts) creates the discrete-time descriptor model
Ex [ n + 1] = Ax [ n] + Bu[ n]
y[ n] = Cx [ n] + Du[ n]
with sample time Ts (in seconds).
sys = dss(A,B,C,D,E,ltisys) creates a descriptor model with
properties inherited from the LTI model ltisys (including the sample
time).
Each pair specifies a particular LTI property of the model, for example,
the input names or some notes on the model history. See set and the
example below for details.
1-130
dss
Examples
The command
sys = dss(1,2,3,4,5,'inputdelay',0.1,'inputname','voltage',...
'notes','Just an example');
5 x = x + 2u
y = 3 x + 4u
with a 0.1 second input delay. The input is labeled 'voltage', and a
note is attached to tell you that this is just an example.
See Also
1-131
dssdata
Purpose
Syntax
[A,B,C,D,E] = dssdata(sys)
[A,B,C,D,E,Ts] = dssdata(sys)
Description
You can access other properties of sys using get or direct structure-like
referencing (e.g., sys.Ts).
For arrays of SS models with variable order, use the syntax
[A,B,C,D,E] = dssdata(sys,'cell')
See Also
1-132
esort
Purpose
Syntax
s = esort(p)
[s,ndx] = esort(p)
Description
Examples
Limitations
See Also
1-133
estim
Purpose
Syntax
est = estim(sys,L)
est = estim(sys,L,sensors,known)
Description
x = Ax + Bw
y = Cx + Dw
estim uses the following equations to generate a plant output estimate
x[ n + 1] = Ax[ n] + Bw[ n]
y[ n] = Cx[ n] + Dw[ n]
estim uses estimator equations similar to those for continuous-time
1-134
estim
x = Ax + B1w + B2u
z C1
D11
D12
y = C x + D w + D u
2
21
22
The index vectors sensors and known specify which outputs of sys are
measured (y), and which inputs of sys are known (u). The resulting
estimator est, found using the following equations, uses both u and y to
produce the output and state estimates.
x = Ax + B2u + L( y C2 x D22u)
y C2
D22
x = I x + 0 u
Tips
You can use the functions place (pole placement) or kalman (Kalman
filtering) to design an adequate estimator gain L. Note that the
estimator poles (eigenvalues of A-LC) should be faster than the plant
dynamics (eigenvalues of A) to ensure accurate estimation.
Examples
Consider a state-space model sys with seven outputs and four inputs.
Suppose you designed a Kalman gain matrix L using outputs 4, 7, and
1 of the plant as sensor measurements and inputs 1, 4, and 3 of the
plant as known (deterministic) inputs. You can then form the Kalman
estimator by
sensors = [4,7,1];
1-135
estim
known = [1,4,3];
est = estim(sys,L,sensors,known)
See Also
1-136
evalfr
Purpose
Syntax
frsp = evalfr(sys,f)
Description
Examples
Example 1
To evaluate the discrete-time transfer function
H ( z) =
z 1
2
z + z+1
at z = 1 + j, type
H = tf([1 -1],[1 1 1],-1);
z = 1+j;
evalfr(H,z)
1.5385e-01i
Example 2
To evaluate the frequency response of a continuous-time IDTF model at
frequency w = 0.1 rad/s, type:
sys = idtf(1,[1 2 1]);
1-137
evalfr
w = 0.1;
s = 1j*w;
evalfr(sys, s)
Limitations
See Also
1-138
lti/exp
Purpose
Syntax
d = exp(tau,s)
Description
See Also
zpk | tf
1-139
fcat
Purpose
Syntax
sys = fcat(sys1,sys2,...)
Description
See Also
1-140
fdel
Purpose
Syntax
Description
sysout = fdel(sys, freq) removes from the frd model sys the data
nearest to the frequency values specified in the vector freq.
Tips
Input
Arguments
sys
frd model.
freq
Output
Arguments
sysout
Examples
Remove selected data from a frd model. In this example, first obtain an
frd model:
frd model containing the data remaining in sys after removing the
frequency points closest to the entries of freq.
Response
-------0.5000 - 0.5000i
0.3748 - 0.4841i
1-141
fdel
1.6681
2.1544
2.7826
3.5938
4.6416
5.9948
7.7426
10.0000
0.2644
0.1773
0.1144
0.0719
0.0444
0.0271
0.0164
0.0099
0.4410i
0.3819i
0.3183i
0.2583i
0.2059i
0.1623i
0.1270i
0.0990i
The following commands remove the data nearest 2, 3.5, and 6 rad/s
from sys.
freq = [2, 3.5, 6];
sysout = fdel(sys, freq)
Frequency(rad/s)
---------------1.0000
1.2915
1.6681
2.7826
4.6416
7.7426
10.0000
Response
-------0.5000 - 0.5000i
0.3748 - 0.4841i
0.2644 - 0.4410i
0.1144 - 0.3183i
0.0444 - 0.2059i
0.0164 - 0.1270i
0.0099 - 0.0990i
You do not have to specify the exact frequency of the data to remove.
fdel removes the data nearest to the specified frequencies.
See Also
1-142
feedback
Purpose
Syntax
sys = feedback(sys1,sys2)
Description
The closed-loop model sys has u as input vector and y as output vector.
The models sys1 and sys2 must be both continuous or both discrete
with identical sample times. Precedence rules are used to determine
the resulting model type (see Rules That Determine Model Type).
To apply positive feedback, use the syntax
sys = feedback(sys1,sys2,+1)
computes a closed-loop model sys for the more general feedback loop.
1-143
feedback
The vector feedin contains indices into the input vector of sys1 and
specifies which inputs u are involved in the feedback loop. Similarly,
feedout specifies which outputs y of sys1 are used for feedback. The
resulting model sys has the same inputs and outputs as sys1 (with
their order preserved). As before, negative feedback is applied by
default and you must use
sys = feedback(sys1,sys2,feedin,feedout,+1)
Examples
Example 1
1-144
feedback
G(s) =
2s2 + 5s + 1
s2 + 2s + 3
H (s) =
5(s + 2)
s + 10
Example 2
Consider a state-space plant P with five inputs and four outputs and a
state-space feedback controller K with three inputs and two outputs. To
connect outputs 1, 3, and 4 of the plant to the controller inputs, and the
controller outputs to inputs 4 and 2 of the plant, use
feedin = [4 2];
feedout = [1 3 4];
Cloop = feedback(P,K,feedin,feedout)
Example 3
You can form the following negative-feedback loops
1-145
feedback
by
Cloop = feedback(G,1)
Cloop = feedback(1,G)
Limitations
% left diagram
% right diagram
See Also
1-146
filt
Purpose
Syntax
sys = filt(num,den)
sys = filt(num,den,Ts)
sys = filt(M)
Description
( )
H z1 =
2 + z1
1 + 0.4 z1 + 2 z2
seconds).
sys = filt(M) specifies a static filter with gain matrix M.
Each pair specifies a particular property of the model, for example, the
input names or the transfer function variable. For information about
the available properties and their values, see the tf reference page.
Arguments
For SISO transfer functions, num and den are row vectors containing the
numerator and denominator coefficients ordered in ascending powers
of z1. For example, den = [1 0.4 2] represents the polynomial
1 + 0.4z1 + 2z2.
1-147
filt
Tips
Examples
num = {1 , [1 0.3]};
den = {[1 1 2] ,[5 2]};
H = filt(num,den,'inputname',{'channel1' 'channel2'})
1-148
filt
See Also
tf | zpk | ss
1-149
fnorm
Purpose
Syntax
fnrm = fnorm(sys)
fnrm = fnorm(sys,ntype)
Description
See Also
1-150
norm | abs
frd
Purpose
Syntax
sys = frd(response,frequency)
sys = frd(response,frequency,Ts)
sys = frd
sysfrd = frd(sys,frequency)
sysfrd = frd(sys,frequency,units)
Description
The input argument list for any of these syntaxes can be followed by
property name/property value pairs of the form
'PropertyName',PropertyValue
You can use these extra arguments to set the various properties the
model. For more information about available properties of frd models,
see Properties on page 1-152.
To force an FRD model sys to inherit all of its generic LTI properties
from any existing LTI model refsys, use the syntax
sys = frd(response,frequency,ltisys)
sysfrd = frd(sys,frequency) converts a dynamic system model sys
1-151
frd
where TimeUnit is the time units of the input dynamic system, specified
in the TimeUnit property of sys.
sysfrd = frd(sys,frequency,units) converts a dynamic system
model to an frd model and interprets frequencies in the frequency
vector to have the units specified by the string units. For a list of values
for the string units, see the FrequencyUnit property in Properties
on page 1-152.
Arguments
SISO model
S1-by-...-by-Sn
array of models
with Ny outputs
and Nu inputs
Properties
1-152
frd
'rad/TimeUnit'
'cycles/TimeUnit'
'rad/s'
'Hz'
'kHz'
'MHz'
'GHz'
'rpm'
The units 'rad/TimeUnit' and 'cycles/TimeUnit' are relative to the
time units specified in the TimeUnit property.
Changing this property changes the overall system behavior. Use
chgFreqUnit to convert between frequency units without modifying
system behavior.
Default: 'rad/TimeUnit'
ResponseData
1-153
frd
Input delay for each input channel, specified as a numeric vector. For
continuous-time systems, specify input delays in the time unit stored
in the TimeUnit property. For discrete-time systems, specify input
delays in integer multiples of the sampling period Ts. For example,
InputDelay = 3 means a delay of three sampling periods.
For a system with Nu inputs, set InputDelay to an Nu-by-1 vector. Each
entry of this vector is a numerical value that represents the input delay
for the corresponding input channel.
You can also set InputDelay to a scalar value to apply the same delay
to all channels.
OutputDelay
1-154
frd
output delays in the time unit stored in the TimeUnit property. For
discrete-time systems, specify output delays in integer multiples of the
sampling period Ts. For example, OutputDelay = 3 means a delay
of three sampling periods.
For a system with Ny outputs, set OutputDelay to an Ny-by-1 vector,
where each entry is a numerical value representing the output delay for
the corresponding output channel. You can also set OutputDelay to a
scalar value to apply the same delay to all channels.
Default: 0 for all output channels
Ts
1-155
frd
'minutes'
'hours'
'days'
'weeks'
'months'
'years'
Changing this property changes the overall system behavior. Use
chgTimeUnit to convert between time units without modifying system
behavior.
Default: 'seconds'
InputName
1-156
frd
InputUnit
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-157
frd
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
1-158
frd
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
SamplingGrid
1-159
frd
t = 0:10. The following code stores the time samples with the linear
models.
sysarr.SamplingGrid = struct('time',0:10)
When you display M, each entry in the array includes the corresponding
zeta and w values.
M
M(:,:,1,1) [zeta=0.3, w=5] =
25
-------------s^2 + 3 s + 25
Default: []
Examples
1-160
frd
freq = logspace(1,2);
resp = .05*(freq).*exp(i*2*freq);
% Create a FRD model
sys = frd(resp,freq);
See Also
Tutorials
Frequency-Response Model
MIMO Frequency Response Data Model
How To
1-161
frdata
Purpose
Syntax
[response,freq] = frdata(sys)
[response,freq,covresp] = frdata(sys)
[response,freq,Ts,covresp] = frdata(sys,'v')
[response,freq,Ts] = frdata(sys)
Description
1-162
frdata
Arguments
Examples
See Also
1-163
freqresp
Purpose
Syntax
[H,wout] = freqresp(sys)
H = freqresp(sys,w)
H = freqresp(sys,w,units)
[H,wout,covH] = freqresp(idsys,...)
Description
Input
Arguments
sys
1-164
freqresp
Output
Arguments
1-165
freqresp
Definitions
Frequency Response
In continuous time, the frequency response at a frequency is the
transfer function value at s = j. For state-space models, this value
is given by
H ( j) = D + C ( j I A)1 B
In discrete time, the frequency response is the transfer function
evaluated at points on the unit circle that correspond to the real
frequencies. freqresp maps the real frequencies w(1),..., w(N) to points
on the unit circle using the transformation z = e jTs . Ts is the sample
time. The function returns the values of the transfer function at the
resulting z values. For models with unspecified sample time, freqresp
uses Ts = 1.
Examples
Frequency Response
Compute the frequency response of the 2-input, 2-output system
1-166
freqresp
0
sys
s 1
s 2
sys11
sys22
sys12
sys21
sys =
1
s 1
= 0;
= 1;
= tf(1,[1 1]);
= tf([1 -1],[1 2]);
[sys11,sys12;sys21,sys22];
[H,wout] = freqresp(sys);
H is a 2-by-2-by-45 array. Each entry H(:,:,k) in H is a 2-by-2 matrix
giving the complex frequency response of all input-output pairs of sys
at the corresponding frequency wout(k). The 45 frequencies in wout are
automatically selected based on the dynamics of sys.
0
sys
s 1
s 2
1
s 1
= 0;
= 1;
= tf(1,[1 1]);
= tf([1 -1],[1 2]);
[sys11,sys12;sys21,sys22];
w = logspace(1,2,200);
1-167
freqresp
H = freqresp(sys,w);
H is a 2-by-2-by-200 array. Each entry H(:,:,k) in H is a 2-by-2 matrix
giving the complex frequency response of all input-output pairs of sys
at the corresponding frequency w(k).
Algorithms
D + C ( j A)1 B, = 1 ,, N
For efficiency, A is reduced to upper Hessenberg form and the linear
equation (j A)X = B is solved at each frequency point, taking
advantage of the Hessenberg structure. The reduction to Hessenberg
form provides a good compromise between efficiency and reliability. See
[1] for more details on this technique.
References
Alternatives
1-168
freqresp
See Also
1-169
freqsep
Purpose
Slow-fast decomposition
Syntax
[Gs,Gf] = freqsep(G,fcut)
[Gs,Gf] = freqsep(G,fcut,options)
Description
slow and fast components around the specified cutoff frequency. The
decomposition is such that G = Gs + Gf.
[Gs,Gf] = freqsep(G,fcut,options) specifies additional options for
the decomposition.
Input
Arguments
1-170
freqsep
Output
Arguments
Gs - Slow dynamics
Examples
1-171
freqsep
Pd has four complex poles and one real pole. The Bode plot shows a
1-172
freqsep
The Bode plot shows that the slow component, Gs, contains only the
lower-frequency resonance. This component also matches the DC
gain of the original model. The fast component, Gf, contains the
higher-frequency resonances and matches the response of the original
model at high frequencies. The sum of the two components Gs+Gf yields
the original model.
1-173
freqsep
Try to decompose the model about 2 rad/s, so that the slow component
cotains the real pole and the fast component contains the complex pair.
[Gs,Gf] = freqsep(G,2);
Warning: One or more fast modes could not be separated from the slow mode
force separation, increase the absolute or relative tolerances ("AbsTol"
"RelTol" options). Type "help freqsepOptions" for more information.
These poles are too close together for freqsep to separate. Increase the
relative tolerance to allow the separation.
options = freqsepOptions('RelTol',1e-4);
[Gs,Gf] = freqsep(G,2,options);
slowpole =
-1.9999
fastpole =
1-174
freqsep
-2.0000 + 0.0001i
-2.0000 - 0.0001i
See Also
freqsepOptions
1-175
freqsepOptions
Purpose
Syntax
opt = freqsepOptions
opt = freqsepOptions(Name,Value)
Description
Input
Arguments
1-176
freqsepOptions
Output
Arguments
Examples
Try to decompose the model about 2 rad/s, so that the slow component
cotains the real pole and the fast component contains the complex pair.
[Gs,Gf] = freqsep(G,2);
Warning: One or more fast modes could not be separated from the slow m
force separation, increase the absolute or relative tolerances ("AbsTo
"RelTol" options). Type "help freqsepOptions" for more information.
These poles are too close together for freqsep to separate. Increase the
relative tolerance to allow the separation.
options = freqsepOptions('RelTol',1e-4);
[Gs,Gf] = freqsep(G,2,options);
1-177
freqsepOptions
slowpole =
-1.9999
fastpole =
-2.0000 + 0.0001i
-2.0000 - 0.0001i
See Also
1-178
freqsep
fselect
Purpose
Syntax
subsys = fselect(sys,fmin,fmax)
subsys = fselect(sys,index)
Description
See Also
1-179
gcare
Purpose
Syntax
[X,L,report] = gcare(H,J,ns)
[X1,X2,D,L] = gcare(H,...,'factor')
Description
F
S1 E
A
H tJ = G A S2 0
S2 S1
R 0
0 0
E 0
0 0
The optional input ns is the row size of the A matrix. Default values for
J and ns correspond to E = I and R = [ ].
Optionally, gcare returns the vector L of closed-loop eigenvalues and a
diagnosis report with value:
-1 if the Hamiltonian pencil has jw-axis eigenvalues
-2 if there is no finite stabilizing solution X
0 if a finite stabilizing solution X exists
This syntax does not issue any error message when X fails to exist.
[X1,X2,D,L] = gcare(H,...,'factor') returns two matrices X1, X2
and a diagonal scaling matrix D such that X = D*(X2/X1)*D. The vector
L contains the closed-loop eigenvalues. All outputs are empty when the
See Also
1-180
care | gdare
gdare
Purpose
Syntax
[X,L,report] = gdare(H,J,ns)
[X1,X2,D,L] = gdare(H,J,NS,'factor')
Description
A F B E
H tJ = Q E S 0
S 0 R 0
0
A 0
B 0
0
See Also
dare | gcare
1-181
genfrd
Purpose
Description
Construction
frequency point in the vector freqs. The frequencies freqs are in the
units specified by the optional argument frequnits. If frequnits is
omitted, the units of freqs are 'rad/TimeUnit'.
frdsys = genfrd(sys,freqs,frequnits,timeunits) further specifies
Input Arguments
sys
1-182
genfrd
String specifying the time units of the genfrd model. Set timeunits to
one of the following values:
'nanoseconds'
'microseconds'
'milliseconds'
'seconds'
'minutes'
'hours'
'days'
'weeks'
'months'
'years'
1-183
genfrd
Default: 'seconds'
Tips
Properties
Blocks
'rad/TimeUnit'
'cycles/TimeUnit'
'rad/s'
'Hz'
'kHz'
1-184
genfrd
'MHz'
'GHz'
'rpm'
The units 'rad/TimeUnit' and 'cycles/TimeUnit' are relative to the
time units specified in the TimeUnit property.
Changing this property changes the overall system behavior. Use
chgFreqUnit to convert between frequency units without modifying
system behavior.
Default: 'rad/TimeUnit'
InputDelay - Input delays
Input delay for each input channel, specified as a numeric vector. For
continuous-time systems, specify input delays in the time unit stored
in the TimeUnit property. For discrete-time systems, specify input
delays in integer multiples of the sampling period Ts. For example,
InputDelay = 3 means a delay of three sampling periods.
For a system with Nu inputs, set InputDelay to an Nu-by-1 vector. Each
entry of this vector is a numerical value that represents the input delay
for the corresponding input channel.
You can also set InputDelay to a scalar value to apply the same delay
to all channels.
OutputDelay
1-185
genfrd
1-186
genfrd
'weeks'
'months'
'years'
Changing this property changes the overall system behavior. Use
chgTimeUnit to convert between time units without modifying system
behavior.
Default: 'seconds'
InputName
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
1-187
genfrd
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-188
genfrd
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
1-189
genfrd
Name
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
SamplingGrid
1-190
genfrd
sysarr.SamplingGrid = struct('time',0:10)
When you display M, each entry in the array includes the corresponding
zeta and w values.
M
M(:,:,1,1) [zeta=0.3, w=5] =
25
-------------s^2 + 3 s + 25
Default: []
See Also
How To
1-191
genmat
Purpose
Description
Construction
Input Arguments
A
1-192
genmat
Properties
Blocks
1-193
genmat
M.SamplingGrid = struct('zeta',zeta,'w',w)
When you display M, each entry in the array includes the corresponding
zeta and w values.
M
M(:,:,1,1) [zeta=0.3, w=5] =
25
-------------s^2 + 3 s + 25
Default: []
Examples
1 a b
M
,
0 ab
where a and b are tunable parameters with initial values 1 and 3,
respectively.
1 Create the tunable parameters using realp.
a = realp('a',-1);
1-194
genmat
b = realp('b',3);
2 Define the generalized matrix using algebraic expressions of a and b.
M = [1 a+b;0 a*b]
M is a generalized matrix whose Blocks property contains a and b.
The initial value of M is M = [1 2;0 -3], from the initial values of
a and b.
3 (Optional) Change the initial value of the parameter a.
M.Blocks.a.Value = -3;
4 (Optional) Use double to display the new value of M.
double(M)
See Also
How To
1-195
gensig
Purpose
Syntax
[u,t] = gensig(type,tau)
[u,t] = gensig(type,tau,Tf,Ts)
Description
available.
'sin'
Sine wave.
Periodic pulse.
You can feed the outputs u and t directly to lsim and simulate the
response of a single-input linear system to the specified signal. Since t
is uniquely determined by Tf and Ts, you can also generate inputs for
multi-input systems by repeated calls to gensig.
Examples
1-196
gensig
See Also
lsim
1-197
genss
Purpose
Description
Construction
1-198
genss
Tips
Properties
Blocks
1-199
genss
Input delay for each input channel, specified as a numeric vector. For
continuous-time systems, specify input delays in the time unit stored
in the TimeUnit property. For discrete-time systems, specify input
delays in integer multiples of the sampling period Ts. For example,
InputDelay = 3 means a delay of three sampling periods.
For a system with Nu inputs, set InputDelay to an Nu-by-1 vector. Each
entry of this vector is a numerical value that represents the input delay
for the corresponding input channel.
You can also set InputDelay to a scalar value to apply the same delay
to all channels.
OutputDelay
1-200
genss
1-201
genss
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
1-202
genss
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-203
genss
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
1-204
genss
SamplingGrid
When you display M, each entry in the array includes the corresponding
zeta and w values.
M
M(:,:,1,1) [zeta=0.3, w=5] =
25
-------------s^2 + 3 s + 25
1-205
genss
Default: []
Examples
a = realp('a',10);
F = tf(a,[1 a]);
F is a genss object which has the tunable parameter a in its Blocks
property. You can connect F with other tunable or numeric models to
1-206
genss
1 a b
A
,
0 ab
3.0
B
,
1 .5
C 0 .3 0 ,
D 0,
where a and b are tunable parameters, whose initial values are 1 and
3, respectively.
1 Create the tunable parameters using realp.
a = realp('a',-1);
b = realp('b',3);
2 Define a generalized matrix using algebraic expressions of a and b.
A = [1 a+b;0 a*b]
A is a generalized matrix whose Blocks property contains a and b.
The initial value of A is M = [1 2;0 -3], from the initial values of
a and b.
3 Create the fixed-value state-space matrices.
B = [-3.0;1.5];
C = [0.3 0];
D = 0;
4 Use ss to create the state-space model.
sys = ss(A,B,C,D)
sys is a generalized LTI model (genss) with tunable parameters a and b.
1-207
genss
F(s)
+
-
C(s)
G(s)
S(s)
The plant response G(s) = 1/(s + 1)2. The model of sensor dynamics is
S(s) = 5/(s + 4). The controller C is a tunable PID controller, and the
prefilter F = a/(s + a) is a low-pass filter with one tunable parameter, a.
Create models representing the plant and sensor dynamics.
Because the plant and sensor dynamics are fixed, represent them using
numeric LTI models zpk and tf.
G = zpk([],[-1,-1],1);
S = tf(5,[1 4]);
Type "pid(C)" to see the current value and "get(C)" to see all properties
C is a ltiblock.pid object, which is a Control Design Block with a
1-208
genss
elements of the control system. The tunable elements are stored in the
Blocks property of the genss model object.
Display the tunable elements of T.
T.Blocks
ans =
C: [1x1 ltiblock.pid]
a: [1x1 realp]
If you have Robust Control Toolbox software, you can use tuning
commands such as systune to tune the free parameters of T to meet
design requirements you specify.
See Also
How To
1-209
get
Purpose
Syntax
Value = get(sys,'PropertyName')
Struct = get(sys)
Description
Examples
1-210
{[0 1]}
{[1 2]}
0
'z'
0.1
0
0
{'voltage'}
{''}
get
InputGroup:
OutputGroup:
Name:
Notes:
UserData:
[1x1 struct]
[1x1 struct]
''
{}
'hello'
and
get(h,'ts')
ans =
0.1000
Tips
For example,
sys.Ts
sys.a
sys.user
1-211
get
return the values of the sample time, A matrix, and UserData property
of the (state-space) model sys.
See Also
1-212
getBlockValue
Purpose
Syntax
val = getBlockValue(M,blockname)
Description
Input
Arguments
Name of the Control Design Block in the model M whose current value is
evaluated.
To get a list of the Control Design Blocks in M, enter M.Blocks.
Output
Arguments
val
Examples
Create a tunable genss model, and evaluate the current value of the
Control Design Blocks of the model.
G
C
a
F
T
=
=
=
=
=
zpk([],[-1,-1],1);
ltiblock.pid('C','PID');
realp('a',10);
tf(a,[1 a]);
feedback(G*C,1)*F;
Cval = getBlockValue(T,'C')
Continuous-time I-only controller:
1
1-213
getBlockValue
Ki * --s
With Ki = 0.001
Cval is a numeric pid controller object.
aval = getBlockValue(T,'a')
aval =
10
aval is a numeric scalar, because a is a real scalar parameter.
See Also
1-214
getCompSensitivity
Purpose
Syntax
T = getCompSensitivity(CL,location)
T = getSensitivity(CL,location,opening)
Description
Input
Arguments
1-215
getCompSensitivity
Output
Arguments
Examples
1-216
getCompSensitivity
+
-
C(s)
G(s)
X
Create a model of the system by specifying and connecting a numeric
LTI plant model G, a tunable controller C, and the loopswitch block X.
Use the loopswitch block to mark the location where you assess the
complementary sensitivity (plant output in this example).
G = tf([1],[1 5]);
C = ltiblock.pid('C','p');
C.Kp.Value = 3;
X = loopswitch('X');
CL = feedback(G*C,X);
CL is a genss model that represents the closed-loop response of the
control system from r to y. The model contains the loopswitch block, X,
that identifies the potential loop-opening location.
1-217
getCompSensitivity
C1
+
-
C2
G2
G1
X2
X1
Create a model of the system by specifying and connecting the numeric
plant models, tunable controllers, and loopswitch blocks. G1 and G2
are plant models, C1 and C2 are tunable controllers, and X1 and X2 are
loopswitch blocks that mark potential loop-opening locations.
G1
G2
C1
C2
X1
X2
CL
=
=
=
=
=
=
=
tf(10,[1 10]);
tf([1 2],[1 0.2 10]);
ltiblock.pid('C','pi');
ltiblock.gain('G',1);
loopswitch('X1');
loopswitch('X2');
feedback(G1*feedback(G2*C2,X2)*C1,X1);
1-218
getCompSensitivity
-s - 2
---------------s^2 + 1.2 s + 12
Continuous-time transfer function.
Definitions
Complementary Sensitivity
The complementary sensitivity function, T, at a point is the closed-loop
transfer function around the feedback loop measured at the specified
location. It is related to the open-loop transfer function, L, and the
sensitivity function, S, at the same point as follows:
L
S 1.
1 L
y
r
+
+
dy
1-219
getCompSensitivity
y GK ( y dy)
y GKy GKdy
( I GK ) y GKdy
y
GK
)1
GK
( I
dy.
T
y
du
1-220
See Also
Tduu
T
Tdu y
+
+
dy
Tdyu
.
Tdy y
getDelayModel
Purpose
Syntax
[H,tau] = getDelayModel(sys)
[A,B1,B2,C1,C2,D11,D12,D21,D22,E,tau] = getDelayModel(sys)
Description
sys
u
H
w
z
exp(-tau*s)
[A,B1,B2,C1,C2,D11,D12,D21,D22,E,tau] = getDelayModel(sys)
returns the set of state-space matrices and internal delay vector, tau,
that explicitly describe the state-space model sys. These state-space
matrices are defined by the state-space equations:
Continuous-time sys:
dx t
Ax t B1u t B2 w t
dt
y t C1 x t D11u t D12 w t
z t C2 x t D21u t D22 w t
wt z t
Discrete-time sys:
1-221
getDelayModel
Ex k 1 Ax k B1u k B2 w k
y k C1 x k D11u k D12 w k
z k C2 x k D21u k D22 w k
w k z k
Input
Arguments
sys
Output
Arguments
Vector of internal delays of sys, expressed in the time units of sys. The
vector tau results from decomposing sys into a delay-free state-space
model H and a component exp(-tau*s) that represents all internal
delays.
If sys has no internal delays, tau is empty.
A,B1,B2,C1,C2,D11,D12,D21,D22,E
Set of state-space matrices that, with the internal delay vector tau,
explicitly describe the state-space model sys.
For explicit state-space models (E = I, or sys.e = []), the output E
= [].
If sys has no internal delays, the outputs B2, C2, D12, D21, and D22
are all empty ([]).
1-222
getDelayModel
Examples
0.5 +
2.3
s
e-2.1s
s +10
See Also
setDelayModel
Concepts
Internal Delays
1-223
getGainCrossover
Purpose
Syntax
wc = getGainCrossover(sys,gain)
Description
Input
Arguments
Output
Arguments
wc - Crossover frequencies
column vector
Examples
1-224
getGainCrossover
G s
s 1 3
and PI controller
C s 1.14
0.454
.
s
G = zpk([],[-1,-1,-1],1);
C = pid(1.14,0.454);
sys = G*C;
wc = getGainCrossover(sys,1)
wc =
0.5214
sys
s2 0.05s 100
.
s2 5s 100
sys is a notch filter centered at 10 rad/s.
sys = tf([1 0.05 100],[1 5 100]);
gain = db2mag(-20);
wc = getGainCrossover(sys,gain)
wc =
9.7531
10.2531
1-225
getGainCrossover
Algorithms
See Also
Concepts
1-226
getIOTransfer
Purpose
Syntax
H = getIOTransfer(T,in,out)
H = getIOTransfer(T,in,out,openings)
Description
Input
Arguments
1-227
getIOTransfer
in
out
loopswitch
+
+
Example: {'r','X1'}
out - Output of extracted transfer function
in
out
loopswitch
1-228
+
+
getIOTransfer
Output
Arguments
Examples
1-229
getIOTransfer
+
-
C1
+
-
C2
d2
d1
G2
G1
X2
X1
If you tuned the free parameters of this model (for example, using the
Robust Control Toolbox tuning command systune), you might want to
analyze the tuned system performance by examining various system
responses.
For example, examine the response at the output, y, to a disturbance
injected at the point d1.
H1 = getIOTransfer(T,'X1','y');
H1 represents the closed-loop response of the control system to
1-230
getIOTransfer
in
out
loopswitch
+
+
response of your tuned system. For example, you can use analysis
commands such as bodeplot or stepplot to analyze H1. You can also
use getValue to obtain the current value of H1, in which all the tunable
blocks are evaluated to their current numeric values.
Similarly, examine the response at the output to a disturbance injected
at the point d2.
H2 = getIOTransfer(T,'X2','y');
1-231
getIOTransfer
+
-
C1
+
-
C2
d2
d1
G2
G1
X2
X1
If you tuned the free parameters of this model (for example, using the
Robust Control Toolbox tuning command systune), you might want to
analyze the tuned system performance by examining various system
responses.
For example, compute the response of the system with the inner loop
open, and the outer loop closed.
H = getIOTransfer(T,'r','y','X2');
1-232
getIOTransfer
Tips
See Also
1-233
getLFTModel
Purpose
Syntax
[H,B,S] = getLFTModel(M)
Description
. . .0
.
..
.
. .
. . . Bk-Sk
B1-S1
..
.
M
The cell array B contains the Control Design Blocks of M. The component
H is a numeric matrix, ss model, or frd model that describes the fixed
portion of M and the interconnections between the blocks of B. The
matrix S = blkdiag(S1,...,Sk) contains numerical offsets that ensure
that the interconnection is well-defined when the current (nominal)
value of M is finite.
1-234
getLFTModel
Tips
Input
Arguments
Output
Arguments
Matrix of offset values. The software might introduce offsets when you
build a Generalized model to ensure that H is finite when the current
(nominal) value of M is finite.
See Also
How To
Generalized Matrices
Generalized and Uncertain LTI Models
Models with Tunable Coefficients
Internal Structure of Generalized Models
1-235
getLoopTransfer
Purpose
Syntax
L = getLoopTransfer(T,Locations)
L = getLoopTransfer(T,Locations,sign)
L = getLoopTransfer(T,Locations,sign,openings)
Description
Input
Arguments
1-236
getLoopTransfer
in
out
loopswitch
+
+
1-237
getLoopTransfer
+
-
C(s)
G(s)
Output
Arguments
1-238
getLoopTransfer
Examples
C(s)
G(s)
=
=
=
=
1-239
getLoopTransfer
The output L is a genss model that includes the tunable block C. You
can use getValue to obtain the current value of L, in which all the
tunable blocks of L are evaluated to their current numeric value.
C(s)
G(s)
=
=
=
=
This command computes the open-loop transfer function from the input
of G to the output of C, assuming that the loop is closed with negative
feedback. That is, the relationships between L and T is given by T
= feedback(L,1). In this example, the positive feedback transfer
function is L(s) = G(s)C(s)
1-240
getLoopTransfer
+
-
C1
+
-
C2
G2
G1
X2
X1
Create a model of the system by specifying and connecting the numeric
plant models G1 and G2, the tunable controllers C1, and the loopswitch
blocks X1 and X2 that mark potential loop-opening locations.
G1 = tf(10,[1 10]);
G2 = tf([1 2],[1 0.2 10]);
C1 = ltiblock.pid('C','pi');
C2 = ltiblock.gain('G',1);
X1 = loopswitch('X1');
X2 = loopswitch('X2');
T = feedback(G1*feedback(G2*C2,X2)*C1,X1);
1-241
getLoopTransfer
Tips
See Also
1-242
getNominal
Purpose
1-243
getoptions
Purpose
Syntax
p = getoptions(h)
p = getoptions(h,propertyname)
Description
See Also
1-244
setoptions
getPeakGain
Purpose
Syntax
gpeak = getPeakGain(sys)
gpeak = getPeakGain(sys,tol)
gpeak = getPeakGain(sys,tol,fband)
[gpeak,fpeak] = getPeakGain( ___ )
Description
If sys is a SISO model, then the peak gain is the largest value of the
frequency response magnitude.
If sys is a MIMO model, then the peak gain is the largest value of
the frequency response 2-norm (the largest singular value across
frequency) of sys. This quantity is also called the L norm of sys,
and coincides with the H norm for stable systems.
If sys is a model that has tunable or uncertain parameters,
getPeakGain evaluates the peak gain at the current or nominal
value of sys.
If sys is a model array, getPeakGain returns an array of the same
size as sys, where gpeak(k) = getPeakGain(sys(:,:,k)) .
gpeak = getPeakGain(sys,tol) returns the peak gain of sys with
fpeak at which the gain achieves the peak value gpeak, and can
include any of the input arguments in previous syntaxes.
1-245
getPeakGain
Input
Arguments
Output
Arguments
Peak gain of the dynamic system model or model array sys, returned as
a scalar value or an array.
If sys is a single model, then gpeak is a scalar value.
If sys is a model array, then gpeak is an array of the same size as
sys, where gpeak(k) = getPeakGain(sys(:,:,k)).
fpeak - Frequency of peak gain
nonnegative real scalar | array of nonnegative real values
Frequency at which the gain achieves the peak value gpeak, returned
as a nonnegative real scalar value or an array of nonnegative real
values. The frequency is expressed in units of rad/TimeUnit, relative
to the TimeUnit property of sys.
If sys is a single model, then fpeak is a scalar.
1-246
getPeakGain
Examples
sys
90
2
s 1.5s 90
sys = tf(90,[1,1.5,90]);
gpeak = getPeakGain(sys);
sys
90
2
s 1.5s 90
sys = tf(90,[1,1.5,90]);
gpeak = getPeakGain(sys,0.0001);
1
100
sys
2
.
2
s 0.2s 1 s s 100
sys is the product of resonances at 1 rad/s and 10 rad/s.
sys = tf(1,[1,.2,1])*tf(100,[1,1,100]);
1-247
getPeakGain
fband = [8,12];
gpeak = getPeakGain(sys,0.01,fband);
The fband argument causes getPeakGain to return the local peak gain
between 8 and 12 rad/s.
1
100
sys
2
.
2
s 0.2s 1 s s 100
sys is the product of resonances at 1 rad/s and 10 rad/s.
sys = tf(1,[1,.2,1])*tf(100,[1,1,100]);
[gpeak,fpeak] = getPeakGain(sys)
gpeak =
5.0502
fpeak =
1.0000
fpeak is the frequency corresponding to the peak gain gpeak. The peak
at 1 rad/s is the overall peak gain of sys.
Algorithms
1-248
getPeakGain
References
[1] Bruisma, N.A. and M. Steinbuch, "A Fast Algorithm to Compute the
H-Norm of a Transfer Function Matrix," System Control Letters, 14
(1990), pp. 287-293.
See Also
Concepts
1-249
getSensitivity
Purpose
Syntax
S = getSensitivity(T,location)
S = getSensitivity(T,location,opening)
Description
If opening and location list the same point, the software opens the
loop after measuring the signal at the point.
Input
Arguments
1-250
getSensitivity
Output
Arguments
S - Sensitivity function
generalized state-space model
Examples
+
-
C(s)
G(s)
1-251
getSensitivity
1-252
getSensitivity
+
-
C1
+
-
C2
G2
G1
X2
X1
Create a model of the system by specifying and connecting the numeric
plant models, tunable controllers, and loopswitch blocks. G1 and G2
are plant models, C1 and C2 are tunable controllers, and X1 and X2 are
loopswitch blocks that mark potential loop-opening locations.
G1 = tf(10,[1 10]);
G2 = tf([1 2],[1 0.2 10]);
C1 = ltiblock.pid('C','pi');
C2 = ltiblock.gain('G',1);
X1 = loopswitch('X1');
X2 = loopswitch('X2');
T = feedback(G1*feedback(G2*C2,X2)*C1,X1);
1-253
getSensitivity
Definitions
Sensitivity Function
The sensitivity function, also referred to simply as sensitivity, measures
how sensitive a signal is to an added disturbance. Feedback reduces the
sensitivity in the frequency band where the open-loop gain is greater
than 1.
Consider the following model:
u
du
r
+
+
u du KGu
( I KG)u du
1
u (
I
KG
) du.
Su
1-254
getSensitivity
u
du
r
Sduu
S
Sdu y
See Also
dy
y
Sdyu
.
Sdy y
1-255
getSwitches
Purpose
Syntax
Locations = getSwitches(T)
Description
Input
Arguments
Output
Arguments
Examples
1-256
getSwitches
+
-
C1
+
-
C2
G2
G1
X2
X1
G1 = tf(10,[1 10]);
G2 = tf([1 2],[1 0.2 10]);
C1 = ltiblock.pid('C','pi');
C2 = ltiblock.gain('G',1);
X1 = loopswitch('X1');
X2 = loopswitch('X2');
T = feedback(G1*feedback(G2*C2,X2)*C1,X1);
T is a genss model whose Control Design Blocks include the tunable
controllers and the switches X1 and X2.
1-257
getSwitches
L = getLoopTransfer(T,'X2',-1,'X1');
See Also
Concepts
Generalized Models
1-258
getValue
Purpose
Syntax
curval = getValue(M)
curval = getValue(M,blockvalues)
curval = getValue(M,Mref)
Description
Input
Arguments
1-259
getValue
Output
Arguments
curval
Examples
+
-
C(s)
G(s)
G s
s 1
s 1 3
G = zpk(1,[-1,-1,-1],1);
C = ltiblock.pid('C','pi');
Try = feedback(G*C,1)
1-260
getValue
The genss model Try has one Control Design Block, C. The block C is
initialized to default values, and the model Try has a current value that
depends on the current value of C. Use getValue to evaluate C and
Try to examine the current values.
1 Evaluate C to obtain its current value.
Cnow = getValue(C)
Tnow = getValue(Try)
You can then access the tuned values of C1 and C2, as well as any
closed-loop model H that depends on C1 and C2, using the following:
C1t = getValue(C1,T);
C2t = getValue(C2,T);
Ht = getValue(H,T);
1-261
getValue
See Also
1-262
gram
Purpose
Syntax
Wc = gram(sys,'c')
Wc = gram(sys,'o')
Description
model sys.
You can use gramians to study the controllability and observability
properties of state-space models and for model reduction [1] . They have
better numerical properties than the controllability and observability
matrices formed by ctrb and obsv.
Given the continuous-time state-space model
x = Ax + Bu
y = Cx + Du
the controllability gramian is defined by
Wc =
0 e
T
BBT e A d
Wo =
AT
0 e
C T Ce A d
1-263
gram
Wc =
Ak BBT ( AT )k ,
k= 0
Wo = ( AT ) k C T CA k
k= 0
respectively.
Algorithms
AWc + Wc AT + BBT = 0
or its discrete-time counterpart
AWc AT Wc + BBT = 0
Similarly, the observability gramian Wo solves the Lyapunov equation
AT Wo + Wo A + C T C = 0
in continuous time, and the Lyapunov equation
AT Wo A Wo + C T C = 0
in discrete time.
Limitations
The A matrix must be stable (all eigenvalues have negative real part in
continuous time, and magnitude strictly less than one in discrete time).
References
See Also
1-264
hasdelay
Purpose
Syntax
B = hasdelay(sys)
B = hasdelay(sys,'elem')
Description
See Also
absorbDelay | totaldelay
1-265
hasInternalDelay
Purpose
Syntax
B = hasInternalDelay(sys)
B = hasInternalDelay(sys,'elem')
Description
Input
Arguments
Output
Arguments
Examples
s = tf('s');
G = exp(-2.4*s)/(s-5);
C = pid(5,0.1);
1-266
hasInternalDelay
sys = feedback(G*C,1);
B = hasInternalDelay(sys)
B =
1
The model sys has an internal delay because of the transfer delay in
the plant G. Therefore, hasInternalDelay returns 1.
See Also
hasdelay | getDelayModel
1-267
hsvd
Purpose
Syntax
hsv = hsvd(sys)
hsv = hsvd(sys,'AbsTol',ATOL,'RelTol',RTOL,'Offset',ALPHA)
hsv = hsvd(sys, opts)
hsvd(sys)
[hsv,baldata] = hsvd(sys)
Description
For models with unstable poles, hsvd only computes the Hankel
singular values of the stable part and entries of hsv corresponding to
unstable modes are set to Inf.
hsv = hsvd(sys,'AbsTol',ATOL,'RelTol',RTOL,'Offset',ALPHA)
1-268
hsvd
Tips
You 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.
Algorithms
The AbsTol, RelTol, and ALPHA parameters are only used for models
with unstable or marginally stable dynamics. Because Hankel singular
values are only meaningful for stable dynamics, hsvd must first split
such models into the sum of their stable and unstable parts:
G = G_s + G_ns
This decomposition can be tricky when the model has modes close to
the stability boundary (e.g., a pole at s=-1e-10), or clusters of modes on
the stability boundary (e.g., double or triple integrators). While hsvd is
able to overcome these difficulties in most cases, it sometimes produces
unexpected results such as
1 Large Hankel singular values for the stable part.
This happens when the stable part G_s contains some poles very
close to the stability boundary. To force such modes into the unstable
group, increase the 'Offset' option to slightly grow the unstable
region.
2 Too many modes are labeled "unstable." For example, you see 5 red
bars in the HSV plot when your model had only 2 unstable poles.
The stable/unstable decomposition algorithm has built-in accuracy
checks that reject decompositions causing a significant loss of
accuracy in the frequency response. Such loss of accuracy arises,
e.g., when trying to split a cluster of stable and unstable modes near
1-269
hsvd
Examples
1-270
hsvd
For a better view of the Hankel singular values, switch the plot to log
scale by selecting Y Scale > Log from the right-click menu.
1-271
hsvd
Notice the dominant Hankel singular value with 1e5 magnitude, due
to the mode s=-1e-7 near the imaginary axis. Set the offset=1e-6 to
treat this mode as unstable
hsvd(sys,'Offset',1e-7)
1-272
hsvd
See Also
1-273
hsvdOptions
Purpose
Syntax
opts = hsvdOptions
opts = hsvdOptions('OptionName', OptionValue)
Description
opts = hsvdOptions returns the default options for the hsvd and
balreal commands.
opts = hsvdOptions('OptionName', OptionValue) accepts one or
more comma-separated name/value pairs. Specify OptionName inside
single quotes.
Input
Arguments
1-274
hsvdOptions
Examples
sys =
( s + 0 .5 )
( s + 106 ) ( s + 2)
Use the Offset option to force hsvd to exclude the pole at s = 106 from
the stable term of the stable/unstable decomposition.
sys = zpk(-.5,[-1e-6 -2],1);
opts = hsvdOptions('Offset',.001); % create option set
hsvd(sys,opts) % treats -1e-6 as unstable
See Also
hsvd | balreal
1-275
hsvoptions
Purpose
Syntax
P = hsvoptions
P = HSVOPTIONS('cstpref')
Description
value (HSV) plots with default values set. You can use these options
to customize the Hankel singular value plot appearance using the
command line.
P = HSVOPTIONS('cstpref') initializes the plot options you selected in
the Control System Toolbox Preferences Editor dialog box. For more
information about the editor, see Toolbox Preferences Editor in the
Users Guide documentation.
This table summarizes the Hankel singular value plot options.
Examples
Option
Description
TickLabel
Grid [off|on]
XlimMode, YlimMode
Limit modes
Xlim, Ylim
Axes limits
YScale [linear|log]
In this example, you set the scale for the Y-axis in the HSV plot.
P = hsvoptions; % Set the Y-axis scale to linear in options
P.YScale = 'linear'; % Create plot with the options specified by P
1-276
hsvoptions
h = hsvplot(rss(2,2,3),P);
The following HSV plot is created, with a linear scale for the Y-axis.
See Also
1-277
hsvplot
Purpose
Syntax
h = hsvplot(sys)
hsvplot(sys)
hsvplot(sys, AbsTol',ATOL,'RelTol',RTOL,'Offset',ALPHA)
hsvplot(AX,sys,...)
Description
Tips
You 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.
Examples
Use the plot handle to change plot options in the Hankel singular
values plot.
sys = rss(20);
h = hsvplot(sys,'AbsTol',1e-6);
% Switch to log scale and modify Offset parameter
setoptions(h,'Yscale','log','Offset',0.3)
See Also
1-278
imp2exp
Purpose
Syntax
B = imp2exp(A,yidx,uidx)
Description
The constraint matrix A can be a double, ss, tf, zpk and frd object
as well as an uncertain object, including umat, uss and ufrd. The result
B will be of the same class.
Examples
and then
B = imp2exp(A,Yidx,Uidx)
B =
-1.7500
1-279
imp2exp
Uidx = [4 2];
B = imp2exp(A,Yidx,Uidx)
B =
0.0020
1.0000
0
0.0020
1-280
imp2exp
P = tf([1],[1 0]);
C = tf([2*.707*1 1^2],[1 0]);
A = [1 -1 0 0 0 -1;0 -C 1 0 0 0;0 0 -1 -1 1 0;0 0 0 0 -P 1];
OutputIndex = [6;3;2;5]; % [y;u;e;f]
InputIndex = [1;4];
% [r;d]
Sys = imp2exp(A,OutputIndex,InputIndex);
Sys.InputName = {'r';'d'};
Sys.OutputName = {'y';'u';'e';'f'};
pole(Sys)
ans =
-0.7070 + 0.7072i
-0.7070 - 0.7072i
step(Sys)
1-281
imp2exp
Algorithms
See Also
iconnect | inv
1-282
impulse
Purpose
Syntax
impulse(sys)
impulse(sys,Tfinal)
impulse(sys,t)
impulse(sys1,sys2,...,sysN)
impulse(sys1,sys2,...,sysN,Tfinal)
impulse(sys1,sys2,...,sysN,t)
[y,t] = impulse(sys)
[y,t] = impulse(sys,Tfinal)
y = impulse(sys,t)
[y,t,x] = impulse(sys)
[y,t,x,ysd] = impulse(sys)
Description
1-283
impulse
See "Plotting and Comparing Multiple Systems" and the bode entry in
this section for more details.
When invoked with output arguments:
[y,t] = impulse(sys)
[y,t] = impulse(sys,Tfinal)
y = impulse(sys,t)
impulse returns the output response y and the time vector t used for
simulation (if not supplied as an argument to impulse). No plot is
drawn on the screen. For single-input systems, y has as many rows
as time samples (length of t), and as many columns as outputs. In
the multi-input case, the impulse responses of each input channel are
stacked up along the third dimension of y. The dimensions of y are then
1-284
impulse
Tips
You 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.
Examples
Example 1
Impulse Response Plot of Second-Order State-Space Model
Plot the impulse response of the second-order state-space model
x1 0.5572 0.7814 x1 1 1 u1
x = 0.7814
x + 0 2 u
0
2
2
2
x1
y = [1.9691 6.4493]
x2
use the following commands.
a = [-0.5572 -0.7814;0.7814
b = [1 -1;0 2];
c = [1.9691 6.4493];
sys = ss(a,b,c,0);
impulse(sys)
0];
1-285
impulse
The left plot shows the impulse response of the first input channel, and
the right plot shows the impulse response of the second input channel.
You can store the impulse response data in MATLAB arrays by
[y,t] = impulse(sys);
Because this system has two inputs, y is a 3-D array with dimensions
size(y)
1-286
impulse
ans =
139
(the first dimension is the length of t). The impulse response of the first
input channel is then accessed by
ch1 = y(:,:,1);
size(ch1)
ans =
139
Example 2
Fetch the impulse response and the corresponding 1 std uncertainty of
an identified linear system.
load(fullfile(matlabroot, 'toolbox', 'ident', 'iddemos', 'data', 'dcmotordata'));
z = iddata(y, u, 0.1, 'Name', 'DC-motor');
set(z, 'InputName', 'Voltage', 'InputUnit', 'V');
set(z, 'OutputName', {'Angular position', 'Angular velocity'});
set(z, 'OutputUnit', {'rad', 'rad/s'});
set(z, 'Tstart', 0, 'TimeUnit', 's');
model = tfest(z,2);
[y,t,~,ysd] = impulse(model,2);
1-287
impulse
subplot(212)
plot(t,y(:,2), t,y(:,2)+3*ysd(:,2),'k:', t,y(:,2)-3*ysd(:,2),'k:')
Algorithms
x = Ax + bu
y = Cx
is equivalent to the following unforced response with initial state b.
x = Ax, x(0) = b
y = Cx
To simulate this response, the system is discretized using zero-order
hold on the inputs. The sampling period is chosen automatically based
on the system dynamics, except when a time vector t = 0:dt:Tf is
supplied (dt is then used as sampling period).
Limitations
See Also
1-288
impulseplot
Purpose
Syntax
impulseplot(sys)
impulseplot(sys,Tfinal)
impulseplot(sys,t)
impulseplot(sys1,sys2,...,sysN)
impulseplot(sys1,sys2,...,sysN,Tfinal)
impulseplot(sys1,sys2,...,sysN,t)
impulseplot(AX,...)
impulseplot(..., plotoptions)
h = impulseplot(...)
Description
applied to each input channel. The time range and number of points are
chosen automatically. For continuous systems with direct feedthrough,
the infinite pulse at t=0 is disregarded. impulseplot can also return
the plot handle, h. You can use this handle to customize the plot with
the getoptions and setoptions commands. Type
help timeoptions
1-289
impulseplot
You can also specify a color, line style, and marker for each system, as in
impulseplot(sys1,'r',sys2,'y--',sys3,'gx')
impulseplot(AX,...) plots into the axes with handle AX.
impulseplot(..., plotoptions) plots the impulse response with the
options specified in plotoptions. Type
help timeoptions
plot handle h.
Tips
You 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.
Examples
Example 1
Normalize the impulse response of a third-order system.
sys = rss(3);
h = impulseplot(sys);
% Normalize responses
setoptions(h,'Normalize','on');
1-290
impulseplot
Example 2
Plot the impulse response and the corresponding 1 std "zero interval" of
an identified linear system.
load(fullfile(matlabroot, 'toolbox', 'ident', 'iddemos', 'data', 'dcmotordata'));
z = iddata(y, u, 0.1, 'Name', 'DC-motor');
set(z, 'InputName', 'Voltage', 'InputUnit', 'V');
set(z, 'OutputName', {'Angular position', 'Angular velocity'});
set(z, 'OutputUnit', {'rad', 'rad/s'});
set(z, 'Tstart', 0, 'TimeUnit', 's');
model = n4sid(z,4,n4sidOptions('Focus', 'simulation'));
h = impulseplot(model,2);
showConfidence(h);
See Also
1-291
initial
Purpose
Syntax
initial(sys,x0)
initial(sys,x0,Tfinal)
initial(sys,x0,t)
initial(sys1,sys2,...,sysN,x0)
initial(sys1,sys2,...,sysN,x0,Tfinal)
initial(sys1,sys2,...,sysN,x0,t)
[y,t,x] = initial(sys,x0)
[y,t,x] = initial(sys,x0,Tfinal)
[y,t,x] = initial(sys,x0,t)
Description
x = Ax, x(0) = x0
y = Cx
This function is applicable to either continuous- or discrete-time models.
When invoked without output arguments, initial plots the initial
condition response on the screen.
initial(sys,x0,Tfinal) simulates the response from t = 0 to the
final time t = Tfinal. Express Tfinal in the system time units,
specified in the TimeUnit property of sys. For discrete-time systems
with unspecified sampling time (Ts = -1), initial interprets Tfinal
as the number of sampling periods to simulate.
initial(sys,x0,t) uses the user-supplied time vector t for simulation.
Express t in the system time units, specified in the TimeUnit property
of sys. For discrete-time models, t should be of the form 0:Ts:Tf,
where Ts is the sample time. For continuous-time models, t should be
of the form 0:dt:Tf, where dt becomes the sample time of a discrete
approximation to the continuous system (see impulse).
1-292
initial
initial(sys1,sys2,...,sysN,x0)
initial(sys1,sys2,...,sysN,x0,Tfinal)
initial(sys1,sys2,...,sysN,x0,t)
return the output response y, the time vector t used for simulation, and
the state trajectories x. No plot is drawn on the screen. The array y has
as many rows as time samples (length of t) and as many columns as
outputs. Similarly, x has length(t) rows and as many columns as
states.
Tips
You 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.
Examples
x1 0.5572 0.7814 x1
x = 0.7814
x
0
2
2
x
y = [1.9691 6.4493] 1
x2
to the initial condition
1
x(0) =
0
a = [-0.5572
-0.7814;0.7814
0];
1-293
initial
c = [1.9691 6.4493];
x0 = [1 ; 0]
sys = ss(a,[],c,[]);
initial(sys,x0)
See Also
1-294
initialplot
Purpose
Syntax
initialplot(sys,x0)
initialplot(sys,x0,Tfinal)
initialplot(sys,x0,t)
initialplot(sys1,sys2,...,sysN,x0)
initialplot(sys1,sys2,...,sysN,x0,Tfinal)
initialplot(sys1,sys2,...,sysN,x0,t)
initialplot(AX,...)
initialplot(..., plotoptions)
h = initialplot(...)
Description
Type
help timeoptions
1-295
initialplot
You can also specify a color, line style, and marker for each system, as in
initialplot(sys1,'r',sys2,'y--',sys3,'gx',x0).
initialplot(AX,...) plots into the axes with handle AX.
initialplot(..., plotoptions) plots the initial condition response
with the options specified in plotoptions. Type
help timeoptions
plot handle h.
Tips
You 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.
Examples
1-296
initialplot
See Also
1-297
interp
Purpose
Syntax
isys = interp(sys,freqs)
Description
You should express the frequency values freqs in the same units as
sys.frequency. The frequency values must lie between the smallest
and largest frequency points in sys (extrapolation is not supported).
See Also
1-298
freqresp | frd
inv
Purpose
Invert models
Syntax
inv
Description
y = G(s)u
to produce the model with the transfer matrix H (s) = G(s)1 .
u = H (s) y
This operation is defined only for square systems (same number of
inputs and outputs) with an invertible feedthrough matrix D. inv
handles both continuous- and discrete-time systems.
Examples
Consider
1
H (s) =
1
s + 1
1-299
inv
s + 1
#2:
Limitations
1-300
inv
------------------(s-1) (s^2 + s + 1)
1-301
iopzmap
Purpose
Syntax
iopzmap(sys)
iopzmap(sys1,sys2,...)
Description
Tips
You 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.
Examples
Example 1
Create a one-input, two-output system and plot pole-zero maps for I/O
pairs.
H = [tf(-5 ,[1 -1]); tf([1 -5 6],[1 1 0])];
iopzmap(H)
1-302
iopzmap
Example 2
View the poles and zeros of an over-parameterized state-space model
estimated using input-output data.
load iddata1
sys = ssest(z1,6,ssestOptions('focus','simulation'))
iopzmap(sys)
The plot shows that there are two pole-zero pairs that almost overlap,
which hints are their potential redundancy.
See Also
1-303
iopzplot
Purpose
Plot pole-zero map for I/O pairs and return plot handle
Syntax
h = iopzplot(sys)
iopzplot(sys1,sys2,...)
iopzplot(AX,...)
iopzplot(..., plotoptions)
Description
iopzplot(sys1,sys2,...)
iopzplot(sys1,'r',sys2,'y',sys3,'g')
iopzplot(AX,...) plots into the axes with handle AX.
iopzplot(..., plotoptions) plots the poles and zeros with the
options specified in plotoptions. Type
help pzoptions
1-304
iopzplot
Tips
You 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.
Examples
Example 1
Use the plot handle to change the I/O grouping of a pole/zero map.
sys = rss(3,2,2);
h = iopzplot(sys);
% View all input-output pairs on a single axis.
setoptions(h,'IOGrouping','all')
Example 2
View the poles and zeros of an over-parameterized state-space model
estimated using input-output data.
load iddata1
sys = ssest(z1,6,ssestOptions('focus','simulation'));
h = iopzplot(sys);
showConfidence(h)
The variability in the pole-zero locations of the second model sys2 are
reduced.
See Also
1-305
isct
Purpose
Syntax
bool = isct(sys)
Description
Input
Arguments
sys
Output
Arguments
bool
See Also
1-306
isdt | isstable
isdt
Purpose
Syntax
bool = isdt(sys)
Description
Input
Arguments
sys
Output
Arguments
bool
0). If sys
For a static gain, both isct and isdt return true unless you explicitly
set the sampling time to a nonzero value. If you do so, isdt returns
true and isct returns false.
For arrays of models, bool is true if the models in the array are
discrete.
See Also
isct | isstable
1-307
isempty
Purpose
Syntax
isempty(sys)
Description
Examples
Both commands
isempty(tf)
isempty(ss(1,2,[],[]))
See Also
1-308
issiso | size
isfinite
Purpose
Syntax
B = isfinite(sys)
B = isfinite(sys,'elem')
Description
Input
Arguments
Output
Arguments
Examples
1-309
isfinite
When you use the 'elem' input, isfinite checks each model
individually and returns a logical array indicating which models have
all finite coefficients.
See Also
1-310
isreal
isParametric
Purpose
Syntax
bool = isParametric(M)
Description
Input
Arguments
Output
Arguments
bool
See Also
nblocks
How To
1-311
isproper
Purpose
Syntax
B = isproper(sys)
B = isproper(sys,'elem')
[B, sysr] = isproper(sys)
Description
Examples
Example 1
The following commands
isproper(tf([1 0],1))
isproper(tf([1 0],[1 1]))
1-312
% transfer function s
% transfer function s/(s+1)
isproper
Example 2
Combining state-space models can yield results that include more states
than necessary. Use isproper to compute an equivalent lower-order
model.
H1 = ss(tf([1 1],[1 2 5]));
H2 = ss(tf([1 7],[1]));
H = H1*H2
a =
x1
-2
2
0
0
x1
x2
x3
x4
x2
-2.5
0
0
0
x3
0.5
0
1
0
x4
1.75
0
0
1
b =
x1
x2
x3
x4
u1
0
0
0
-4
c =
y1
x1
1
x2
0.5
x3
0
x4
0
x2
0
1
x3
0
0
x4
0
0
d =
y1
u1
0
e =
x1
x2
x1
1
0
1-313
isproper
x3
x4
0
0
0
0
0
0
0.5
0
a =
x1
x2
x1
0
-0.06988
x1
x2
u1
-0.125
-0.1398
x2
0.1398
-0.0625
b =
c =
x1
-0.5
y1
x2
-1.118
d =
y1
u1
1
e =
x1
x2
x1
0.0625
0
x2
0
0.03125
Continuous-time model.
1-314
isproper
See Also
ss | dss
1-315
isreal
Purpose
Syntax
B = isreal(sys)
B = isreal(sys,'elem')
Description
and returns a logical array of the same size as sys. The logical array
indicates which models in sys have real coefficients.
Input
Arguments
Output
Arguments
Examples
1-316
isreal
When you use the 'elem' input, isreal checks each model individually
and returns a logical array indicating which models have all real-valued
coefficients.
See Also
isfinite
1-317
isstable
Purpose
Syntax
B = isstable(sys)
B = isstable(sys,'elem')
Description
of poles.
See Also
1-318
pole
issiso
Purpose
Syntax
issiso(sys)
Description
See Also
isempty | size
1-319
isstatic
Purpose
Syntax
B = isstatic(sys)
B = isstatic(sys,'elem')
Description
Input
Arguments
Output
Arguments
See Also
Concepts
1-320
kalman
Purpose
Syntax
[kest,L,P] = kalman(sys,Qn,Rn,Nn)
[kest,L,P] = kalman(sys,Qn,Rn,Nn,sensors,known)
[kest,L,P,M,Z] = kalman(sys,Qn,Rn,...,type)
Description
Continuous-Time Estimation
Given the continuous plant
x = Ax + Bu + Gw
y = Cx + Du + Hw + v
(state equation)
(measurement equation))
E(w) = E(v) = 0,
E(wwT ) = Q,
E(vvT ) = R,
E(wvT ) = N
T
P = lim E {x x }{x x }
t
x = Ax + Bu + L( y Cx Du)
y C
D
x = I x + 0 u
The filter gain L is determined by solving an algebraic Riccati equation
to be
1-321
kalman
L = ( PC T + N ) R1
where
R = R + HN + N T H T + HQH T
N = G(QH T + N )
and P solves the corresponding algebraic Riccati equation.
The estimator uses the known inputs u and the measurements y
to generate the output and state estimates y and x . Note that y
estimates the true plant output
y = Cx + Du + Hw + v
u
u
w
Kalman
Filter
y
Plant
y
x
v
Kalman Estimator
Discrete-Time Estimation
Given the discrete plant
1-322
kalman
R = R + HN + N T H T + HQH T
N = G(QH T + N )
There are two variants of discrete-time Kalman estimators:
The current estimator generates output estimates y[ n| n] and state
estimates x[ n| n] using all available measurements up to y[ n] . This
estimator has the output equation
y[ n| n] C( I MC)
( I CM ) D CM u[ n]
x[ n| n] = I MC x[ n| n 1] + MD
M y[ n]
where the innovation gain M is defined as
M = PC T (CPC T + R)1
M updates the prediction x[ n| n 1] using the new measurement
y[ n] .
x[ n| n] = x[ n| n 1] + M ( y[ n] Cx[ n| n 1] Du[ n])
innovation
1-323
kalman
y[ n| n 1] C
D 0 u[ n]
x[ n| n 1] = I x[ n| n 1] + 0 0 y[ n]
[kest,L,P] = kalman(sys,Qn,Rn,Nn) creates a state-space model
kest of the Kalman estimator given the plant model sys and the noise
covariance data Qn, Rn, Nn (matrices Q, R, N described in Description
on page 1-321). sys must be a state-space model with matrices
A,[ B G ], C,[ D H ] .
The resulting estimator kest has inputs [u; y] and outputs [ y ; x ] (or
their discrete-time counterparts). You can omit the last input argument
Nn when N = 0.
The function kalman handles both continuous and discrete problems
and produces a continuous estimator when sys is continuous and a
discrete estimator otherwise. In continuous time, kalman also returns
the Kalman gain L and the steady-state error covariance matrix P. P
solves the associated Riccati equation.
[kest,L,P] = kalman(sys,Qn,Rn,Nn,sensors,known) handles the
1-324
kalman
e[ n| n 1] = x[ n] x[ n| n 1]
e[ n| n] = x[ n] x[ n| n]
Examples
See LQG Design for the x-Axis and Kalman Filtering for examples that
use the kalman function.
Limitations
Q = GQG T
R = R + HN + N T H T + HQH T
N = G(QH T + N )
References
[1] Franklin, G.F., J.D. Powell, and M.L. Workman, Digital Control of
Dynamic Systems, Second Edition, Addison-Wesley, 1990.
[2] Lewis, F., Optimal Estimation, John Wiley & Sons, Inc, 1986.
See Also
1-325
kalmd
Purpose
Syntax
kalmd
[kest,L,P,M,Z] = kalmd(sys,Qn,Rn,Ts)
Description
x = Ax + Bu + gw (state equation)
(measurement equation))
yv = Cx + Du + v
with process noise w and measurement noise v satisfying
Qd =
Ts A
T
GQG T e A d
Rd = R / Ts
The integral is computed using the matrix exponential formulas in [2].
A discrete-time estimator is then designed for the discretized plant and
noise. See kalman for details on discrete-time Kalman estimation.
kalmd also returns the estimator gains L and M, and the discrete error
covariance matrices P and Z (see kalman for details).
1-326
kalmd
Limitations
References
[1] Franklin, G.F., J.D. Powell, and M.L. Workman, Digital Control of
Dynamic Systems, Second Edition, Addison-Wesley, 1990.
[2] Van Loan, C.F., "Computing Integrals Involving the Matrix
Exponential," IEEE Trans. Automatic Control, AC-15, October 1970.
See Also
1-327
lft
Purpose
Syntax
lft
sys = lft(sys1,sys2,nu,ny)
Description
models (or arrays) sys1 and sys2. The star product amounts to the
following feedback connection for single models (or for each model in an
array).
This feedback loop connects the first nu outputs of sys2 to the last nu
inputs of sys1 (signals u), and the last ny outputs of sys1 to the first
ny inputs of sys2 (signals y). The resulting system sys maps the input
vector [w1 ; w2] to the output vector [z1 ; z2].
The abbreviated syntax
1-328
lft
sys = lft(sys1,sys2)
produces:
The lower LFT of sys1 and sys2 if sys2 has fewer inputs and outputs
than sys1. This amounts to deleting w2 and z2 in the above diagram.
The upper LFT of sys1 and sys2 if sys1 has fewer inputs and outputs
than sys2. This amounts to deleting w1 and z1 in the above diagram.
Algorithms
Limitations
See Also
connect | feedback
1-329
loopswitch
Purpose
Syntax
S = loopswitch(name)
S = loopswitch(name,N)
Description
Construction
with N channels.
Input Arguments
name
1-330
loopswitch
Tips
Properties
Location
1-331
loopswitch
1-332
loopswitch
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
1-333
loopswitch
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-334
loopswitch
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
1-335
loopswitch
Examples
C(s)
G(s)
X
G = 1/(s+2) is the plant model, C is a tunable PI controller, and X is a
loop-opening switch.
G
C
X
T
=
=
=
=
tf(1,[1 2]);
ltiblock.pid('C','pi');
loopswitch('X');
feedback(G*C,X);
1-336
loopswitch
1-337
loopswitch
See Also
genss | getSwitches
How To
1-338
lqg
Purpose
Syntax
reg
reg
reg
reg
Description
=
=
=
=
lqg(sys,QXU,QWV)
lqg(sys,QXU,QWV,QI)
lqg(sys,QXU,QWV,QI,'1dof')
lqg(sys,QXU,QWV,QI,'2dof')
signal u that regulates y around the zero value. Use positive feedback
to connect this regulator to the plant output y.
w
reg
sys
x
1
J E lim xT , uT Qxu dt
u
0
subject to the plant equations
dx/dt = Ax + Bu + w
y
= Cx + Du + v
1-339
lqg
reg
sys
x
1
J E lim xT , uT Qxu xiT Qi xi dt
0
u
where xi is the integral of the tracking error r - y. For MIMO systems, r,
y, and xi must have the same length.
reg = lqg(sys,QXU,QWV,QI,'1dof') computes a
one-degree-of-freedom servo controller that takes e = r - y
rather than [r ; y] as input.
reg = lqg(sys,QXU,QWV,QI,'2dof') is equivalent to
LQG(sys,QXU,QWV,QI) and produces the two-degree-of-freedom
Tips
To compute the LQG regulator, lqg uses the commands lqr and
kalman. To compute the servo-controller, lqg uses the commands lqi
and kalman.
1-340
lqg
When you want more flexibility for designing regulators you can use the
lqr, kalman, and lqgreg commands. When you want more flexibility for
designing servo controllers, you can use the lqi, kalman, and lqgtrack
commands. For more information on using these commands and how
to decide when to use them, see Linear-Quadratic-Gaussian (LQG)
Design for Regulation and Linear-Quadratic-Gaussian (LQG) Design
of Servo Controller with Integral Action.
Examples
w
r
trksys
Plant
The plant has three states (x), two control inputs (u), three random
inputs (w), one output (y), measurement noise for the output (v), and
the following state and measurement equations.
dx
= Ax + Bu + w
dt
y = Cx + Du + v
where
1-341
lqg
0 1 0
A = 0 0 1
1 0 0
1
0 .3
B= 0
1
0.3 0.9
C = [1.9 1.3 1]
D = [0.53 0.61]
Qn = E
( )
4 2 0
= 2 1 0
0 0 1
Rn = E vvT = 0.7
For the regulator, use the following cost function to define the tradeoff
between regulation performance and control effort:
J (u) =
0 0.1x
1 0
x + uT
u dt
0 2
For the servo controllers, use the following cost function to define the
tradeoff between tracker performance and control effort:
J (u) =
0 0.1x
1 0
x + xi2 + uT
u dt
0 2
1-342
=
=
=
=
lqg
sys = ss(A,B,C,D);
2 Define the noise covariance data and the weighting matrices by
KLQG = lqg(sys,QXU,QWV)
x1_e
-6.212
-4.038
-1.418
x1_e
x2_e
x3_e
y1
2.365
1.432
0.7684
x2_e
-3.814
-3.196
-1.973
x3_e
-4.136
-1.791
-1.766
b =
c =
u1
u2
x1_e
-0.02904
-0.7147
x2_e
0.0008272
-0.7115
x3_e
0.0303
-0.7132
d =
1-343
lqg
u1
u2
y1
0
0
Input groups:
Name
Measurement
Output groups:
Name
Controls
Channels
1
Channels
1,2
Continuous-time model.
4 Form the one-degree-of-freedom LQG servo controller by typing the
following command:
KLQG1 = lqg(sys,QXU,QWV,QI,'1dof')
x1_e
-7.626
-5.108
-2.121
0
x1_e
x2_e
x3_e
xi1
e1
-2.365
-1.432
-0.7684
1
x2_e
-5.068
-4.146
-2.604
0
x3_e
-4.891
-2.362
-2.141
0
xi1
0.9018
0.6762
0.4088
0
b =
c =
u1
1-344
x1_e
-0.5388
x2_e
-0.4173
x3_e
-0.2481
xi1
0.5578
lqg
u2
-1.492
-1.388
-1.131
0.5869
d =
u1
u2
e1
0
0
Input groups:
Name
Channels
Error
1
Output groups:
Name
Controls
Channels
1,2
Continuous-time model.
5 Form the two-degree-of-freedom LQG servo controller by typing the
following command:
KLQG2 = lqg(sys,QXU,QWV,QI,'2dof')
x1_e
-7.626
-5.108
-2.121
0
x2_e
-5.068
-4.146
-2.604
0
x1_e
x2_e
x3_e
xi1
r1
0
0
0
1
y1
2.365
1.432
0.7684
-1
x3_e
-4.891
-2.362
-2.141
0
xi1
0.9018
0.6762
0.4088
0
b =
1-345
lqg
c =
u1
u2
x1_e
-0.5388
-1.492
u1
u2
r1
0
0
x2_e
-0.4173
-1.388
x3_e
-0.2481
-1.131
xi1
0.5578
0.5869
d =
y1
0
0
Input groups:
Name
Setpoint
Measurement
Output groups:
Name
Controls
Channels
1
2
Channels
1,2
Continuous-time model.
See Also
1-346
lqgreg
Purpose
Syntax
rlqg = lqgreg(kest,k)
rlqg = lqgreg(kest,k,controls)
Description
u = Kx
where x is the Kalman state estimate. The regulator state-space
equations are
x = [ A LC ( B LD) K ]x + Ly
u = Kx
where y is the vector of plant output measurements (see kalman for
background and notation). The following diagram shows this dynamic
regulator in relation to the plant.
w
kest
-K
sys
LQG Regulator
1-347
lqgreg
In discrete time, you can form the LQG regulator using either the
delayed state estimate x[ n| n 1] of x[n], based on measurements up
to y[n1], or the current state estimate x[ n| n] , based on all available
measurements including y[n]. While the regulator
u [ n] = Kx [ n| n 1]
is always well-defined, the current regulator
u [ n] = Kx [ n| n]
is causal only when I-KMD is invertible (see kalman for the notation).
In addition, practical implementations of the current regulator should
allow for the processing time required to compute u[n] after the
measurements y[n] become available (this amounts to a time delay in
the feedback loop).
Tips
Discrete regulator for discrete plant: use dlqr or lqry and kalman
Discrete regulator for continuous plant: use lqrd and kalmd
In discrete time, lqgreg produces the regulator
u [ n] = Kx [ n| n] when kest is the current Kalman estimator
u [ n] = Kx [ n| n 1] when kest is the delayed Kalman estimator
For more information on Kalman estimators, see the kalman reference
page.
1-348
lqgreg
u
ud
y
kest
-K
LQG Regulator
Examples
See Also
1-349
lqgtrack
Purpose
Syntax
C
C
C
C
Description
=
=
=
=
lqgtrack(kest,k)
lqgtrack(kest,k,'2dof')
lqgtrack(kest,k,'1dof')
lqgtrack(kest,k,...CONTROLS)
w
r
y
Plant
Note Always use positive feedback to connect the LQG servo controller
C to the plant output y.
C = lqgtrack(kest,k) forms a two-degree-of-freedom LQG servo
controller C by connecting the Kalman estimator kest and the
state-feedback gain k, as shown in the following figure. C has inputs
1-350
lqgtrack
kest
r
r-y
-
Integrator
-K
xi
y
LQG Servo Controller
The size of the gain matrix k determines the length of xi. xi, y, and r
all have the same length.
The two-degree-of-freedom LQG servo controller state-space equations
are
x A BK x LC + LDK x
=
0
x i
x
u = [ K x Ki ]
xi
BK i + LDK i x 0 L r
x + I I y
0
i
1-351
lqgtrack
u
e
r-y
-1
kest
Integrator
-K
xi
x A BK x LC + LDK x
=
0
x i
x
u = [ K x Ki ]
xi
BK i + LDK i x L
x + I e
0
i
1-352
lqgtrack
u
Ud
kest
r-y
-
Integrator
-K
xi
y
LQG Servo Controller
Tips
You can use lqgtrack for both continuous- and discrete-time systems.
In discrete-time systems, integrators are based on forward Euler (see
lqi for details). The state estimate x is either x[n|n] or x[n|n1],
depending on the type of estimator (see kalman for details).
Examples
See Also
1-353
lqi
Purpose
Linear-Quadratic-Integral control
Syntax
[K,S,e] = lqi(SYS,Q,R,N)
Description
x
r
e = r-y
Integrator
xi
-K
sys
For a plant sys with the state-space equations (or their discrete
counterpart):
dx
= Ax + Bu
dt
y = Cx + Du
the state-feedback control is of the form
u = K[ x; xi ]
where xi is the integrator output. This control law ensures that the
output y tracks the reference command r. For MIMO systems, the
number of integrators equals the dimension of the output y.
[K,S,e] = lqi(SYS,Q,R,N) calculates the optimal gain matrix K,
given a state-space model SYS for the plant and weighting matrices Q,
R, N. The control law u = Kz = K[x;xi] minimizes the following cost
functions (for r = 0)
J (u) =
1-354
0 { z
lqi
Tips
state-space model
dx
= E 1 Ax + E 1 Bu
dt
Limitations
z
= Aa z + Ba u
t
y = Ca z + Da u
The problem data must satisfy:
The pair (Aa,Ba) is stabilizable.
R > 0 and Q NR1 N T 0 .
1-355
lqi
References
See Also
1-356
lqr
Purpose
Syntax
[K,S,e] = lqr(SYS,Q,R,N)
[K,S,e] = LQR(A,B,Q,R,N)
Description
J (u) =
0 ( x
Qx + uT Ru + 2 xT Nu) dt
x = Ax + Bu.
In addition to the state-feedback gain K, lqr returns the solution S of
the associated Riccati equation
AT S + SA ( SB + N ) R1 ( BT S + N T ) + Q = 0
and the closed-loop eigenvalues e = eig(A-B*K). K is derived from
S using
K = R1 ( BT S + N T )
For a discrete-time state-space model, u[n] = Kx[n] minimizes
J=
{ xT Qx + uT Ru + 2 xT Nu}
n =0
1-357
lqr
Tips
state-space model:
dx
= E 1 Ax + E 1 Bu
dt
Limitations
See Also
1-358
lqrd
Purpose
Syntax
lqrd
[Kd,S,e] = lqrd(A,B,Q,R,Ts)
[Kd,S,e] = lqrd(A,B,Q,R,N,Ts)
Description
law
u[ n] = K d x[ n]
that minimizes a discrete cost function equivalent to the continuous
cost function
J=
0 ( x
Qx + uT Ru )dt
x = Ax + Bu
and Ts specifies the sample time of the discrete regulator. Also returned
are the solution S of the discrete Riccati equation for the discretized
problem and the discrete closed-loop eigenvalues e = eig(Ad-Bd*Kd).
[Kd,S,e] = lqrd(A,B,Q,R,N,Ts) solves the more general problem
with a cross-coupling term in the cost function.
J=
0 ( x
Qx + uT Ru + 2 xT Nu ) dt
1-359
lqrd
Algorithms
( ) = e A ,
( ) =
Ad = (Ts )
A
e Bd ,
0
Bd = (Ts )
x[ n + 1] = Ad x[ n] + Bd u[ n]
and the weighting matrices for the equivalent discrete cost function are
Qd
T
N d
Nd
=
Rd
Ts
T
( ) 0 Q
T ( ) I N T
N ( ) ( )
d
I
R 0
Limitations
The discretized problem data should meet the requirements for dlqr.
References
[1] Franklin, G.F., J.D. Powell, and M.L. Workman, Digital Control of
Dynamic Systems, Second Edition, Addison-Wesley, 1980, pp. 439-440.
[2] Van Loan, C.F., "Computing Integrals Involving the Matrix
Exponential," IEEE Trans. Automatic Control, AC-23, June 1978.
See Also
1-360
lqry
Purpose
Syntax
[K,S,e] = lqry(sys,Q,R,N)
Description
x = Ax + Bu
y = Cx + Du
or its discrete-time counterpart, lqry designs a state-feedback control
u = Kx
that minimizes the quadratic cost function with output weighting
J (u) = ( yT Qy + uT Ru + 2 yT Nu) dt
0
Q
T
N
N CT
=
R DT
0 Q
T
I N
N C
R 0
D
I
Examples
Limitations
See Also
1-361
lsim
Purpose
Syntax
lsim
lsim(sys,u,t)
lsim(sys,u,t,x0)
lsim(sys,u,t,x0,'zoh')
lsim(sys,u,t,x0,'foh')
lsim(sys)
Description
the time samples for the simulation (in system time units, specified in
the TimeUnit property of sys), and consists of regularly spaced time
samples.
t = 0:dt:Tfinal
1-362
lsim
simulates the responses of several LTI models to the same input history
t,u and plots these responses on a single figure. As with bode or plot,
you can specify a particular color, linestyle, and/or marker for each
system, for example,
lsim(sys1,'y:',sys2,'g--',u,t,x0)
return the output response y, the time vector t used for simulation,
and the state trajectories x (for state-space models only). No plot is
drawn on the screen. The matrix y has as many rows as time samples
(length(t)) and as many columns as system outputs. The same holds
for x with "outputs" replaced by states.
lsim(sys) opens the Linear Simulation Tool GUI. For more
information about working with this GUI, see Working with the Linear
Simulation Tool.
Examples
Example 1
Simulate and plot the response of the system
1-363
lsim
2s2 + 5s + 1
2
H (s) = s + 2s + 3
s 1
2
s + s+5
to a square wave with period of four seconds. First generate the square
wave with gensig. Sample every 0.1 second during 10 seconds:
[u,t] = gensig('square',4,10,0.1);
1-364
lsim
Example 2
Simulate the response of an identified linear model using the same
input signal as the one used for estimation and the initial states
returned by the estimation command.
Algorithms
H (s) =
2
2
s + 2s + 2
, = 62.83
To simulate its response to a square wave with period 1 second, you can
proceed as follows:
w2 = 62.83^2
h = tf(w2,[1 2 w2])
t = 0:0.1:5;
u = (rem(t,1)>=0.5);
1-365
lsim
lsim(h,u,t)
lsim evaluates the specified sample time, gives this warning
Warning: Input signal is undersampled. Sample every 0.016 sec or
faster.
1-366
lsim
See Also
1-367
lsiminfo
Purpose
Syntax
S = lsiminfo(y,t,yfinal)
S = lsiminfo(y,t)
S = lsiminfo(...,'SettlingTimeThreshold',ST)
Description
Examples
1-368
lsiminfo
SettlingTime:
Min:
MinTime:
Max:
MaxTime:
See Also
22.8626
-0.4270
2.0309
0.2845
4.0619
1-369
lsimplot
Purpose
Syntax
h = lsimplot(sys)
lsimplot(sys1,sys2,...)
lsimplot(sys,u,t)
lsimplot(sys,u,t,x0)
lsimplot(sys1,sys2,...,u,t,x0)
lsimplot(AX,...)
lsimplot(..., plotoptions)
lsimplot(sys,u,t,x0,'zoh')
lsimplot(sys,u,t,x0,'foh')
Description
input(s), the time vector, and initial state. It also returns the plot
handle h. You can use this handle to customize the plot with the
getoptions and setoptions commands. Type
help timeoptions
1-370
lsimplot
lsimplot(sys,u,t)
optional. You can also specify a color, line style, and marker for each
system, as in
lsimplot(sys1,'r',sys2,'y--',sys3,'gx',u,t)
lsimplot(AX,...) plots into the axes with handle AX.
lsimplot(..., plotoptions) plots the initial condition response with
the options specified in plotoptions. Type
help timeoptions
See Also
1-371
ltiblock.gain
Purpose
Syntax
blk = ltiblock.gain(name,Ny,Nu)
blk = ltiblock.gain(name,G)
Description
Model object for creating tunable static gains. ltiblock.gain lets you
parametrize tunable static gains for parameter studies or for automatic
tuning with Robust Control Toolbox tuning commands such as systune
or looptune.
ltiblock.gain is part of the Control Design Block family of
parametric models. Other Control Design Blocks includeltiblock.pid,
ltiblock.ss, and ltiblock.tf.
Construction
Input Arguments
name
1-372
ltiblock.gain
Double array of static gain values. The number of rows and columns of
G determine the number of inputs and outputs of blk. The entries G are
the initial values of the parametric gain block parameters.
Tips
Properties
Gain
Field
Description
Value
1-373
ltiblock.gain
Field
Description
blk.Gain.Free.
Default: Array of zero values.
Free
1-374
Minimum
Maximum
ltiblock.gain
Ts
1-375
ltiblock.gain
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
1-376
ltiblock.gain
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-377
ltiblock.gain
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
1-378
ltiblock.gain
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
Examples
g1
0
0
g2
% set diagonals to 1
1-379
ltiblock.gain
Create a 2by-2 parametric gain block and assign names to the inputs.
blk = ltiblock.gain('gainblock',2,2)
blk.InputName = {'Xerror','Yerror'}
% 2 outputs, 2 inputs
% assign input names
See Also
How To
1-380
ltiblock.pid
Purpose
Syntax
blk = ltiblock.pid(name,type)
blk = ltiblock.pid(name,type,Ts)
blk = ltiblock.pid(name,sys)
Description
Construction
blk = K p +
Ki
Kds
+
,
s 1 + Tf s
with tunable parameters Kp, Ki, Kd, and Tf. The string type sets
the controller type by fixing some of these values to zero (see Input
Arguments on page 1-382).
blk = ltiblock.pid(name,type,Ts) creates a discrete-time PID
blk = K p + K i IF ( z ) +
Kd
,
Tf + DF ( z )
where IF(z) and DF(z) are the discrete integrator formulas for the
integral and derivative terms, respectively. The values of the IFormula
and DFormula properties set the discrete integrator formulas (see
Properties on page 1-383).
1-381
ltiblock.pid
Input Arguments
name
Controller Type
Effect on PID
Parameters
'P'
Proportional only
'PI'
Proportional-integral
Kd is fixed to zero; Tf
is fixed to 1; Kp and
Ki are free
'PD'
'PID'
Proportional-integral-derivative
Kp, Ki, Kd, and Tf are
with first-order filter free
on derivative action
Ts
1-382
ltiblock.pid
Properties
Parametrization of the PID gains Kp, Ki, Kd, and filter time constant Tf
of the tunable PID controller blk.
The following fields of blk.Kp, blk.Ki, blk.Kd, and blk.Tf are used
when you tune blk using a tuning command such as systune:
Field
Description
Value
Free
Minimum
Maximum
1-383
ltiblock.pid
Strings setting the discrete integrator formulas IF(z) and DF(z) for the
integral and derivative terms, respectively. IFormula and DFormula can
have the following values:
String
'ForwardEuler'
Ts
z 1
'BackwardEuler'
Ts z
z 1
'Trapezoidal'
Ts z + 1
2 z 1
Default: 'ForwardEuler'
Ts
1-384
ltiblock.pid
1-385
ltiblock.pid
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
1-386
ltiblock.pid
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-387
ltiblock.pid
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
1-388
ltiblock.pid
Examples
to
to
Tf
Tf
4
0.7
to 0.01
to this value
blk =
Parametric continuous-time PID controller "pdblock" with formula:
s
Kp + Kd * -------Tf*s+1
and tunable parameters Kp, Kd.
Type "pid(blk)" to see the current value and "get(blk)" to see all pro
1-389
ltiblock.pid
Kp + Ki * -----z-1
and tunable parameters Kp, Ki.
Type "pid(blk)" to see the current value and "get(blk)" to see all proper
blk takes the value of properties, such as Ts and IFormula, from C.
Tips
You can modify the PID structure by fixing or freeing any of the
parameters Kp, Ki, Kd, and Tf. For example, blk.Tf.Free = false
fixes Tf to its current value.
To convert an ltiblock.pid parametric model to a numeric
(nontunable) model object, use model commands such as pid, pidstd,
tf, or ss. You can also use getValue to obtain the current value
of a tunable model.
See Also
How To
1-390
ltiblock.pid2
Purpose
Syntax
blk = ltiblock.pid2(name,type)
blk = ltiblock.pid2(name,type,Ts)
blk = ltiblock.pid2(name,sys)
Description
Construction
u K p br y
Ki
K s
r y d cr y .
s
1 Tf s
r
y
blk
1-391
ltiblock.pid2
The string type sets the controller type by fixing some of these values
to zero (see Input Arguments on page 1-392).
blk = ltiblock.pid2(name,type,Ts) creates a discrete-time PID
controller with sampling time Ts. The equation describing this
controller is:
u K p br y K i IF z r y
Kd
cr y .
Tf DF z
IF(z) and DF(z) are the discrete integrator formulas for the integral
and derivative terms, respectively. The values of the IFormula
and DFormula properties set the discrete integrator formulas (see
Properties on page 1-393).
blk = ltiblock.pid2(name,sys) uses the dynamic system model,
sys, to set the sampling time, Ts, and the initial values of all the
Input Arguments
name
1-392
ltiblock.pid2
String
Controller Type
Effect on PID
Parameters
'P'
Proportional only
'PI'
Proportional-integral
Kd is fixed to zero; Tf
is fixed to 1; Kp and
Ki are free
'PD'
'PID'
Proportional-integral-derivative
Kp, Ki, Kd, and Tf are
with first-order filter free
on derivative action
Ts
Properties
Kp,Ki,Kd,Tf,b,c
Parametrization of the PID gains Kp, Ki, Kd, the filter time constant,
Tf, and the scalar gains, b and c.
The following fields of blk.Kp, blk.Ki, blk.Kd, blk.Tf, blk.b, and
blk.c are used when you tune blk using a tuning command such as
systune:
1-393
ltiblock.pid2
Field
Description
Value
Free
Minimum
Maximum
reference page.
IFormula, DFormula
1-394
ltiblock.pid2
Strings setting the discrete integrator formulas IF(z) and DF(z) for the
integral and derivative terms, respectively. IFormula and DFormula can
have the following values:
String
'ForwardEuler'
Ts
z 1
'BackwardEuler'
Ts z
z 1
'Trapezoidal'
Ts z + 1
2 z 1
Default: 'ForwardEuler'
Ts
1-395
ltiblock.pid2
1-396
ltiblock.pid2
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-397
ltiblock.pid2
OutputName
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
1-398
ltiblock.pid2
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
Examples
1-399
ltiblock.pid2
blk = ltiblock.pid2('pdblock','PD');
blk.b.Value = 1;
blk.c.Value = 0.5;
blk.Tf.Value = 0.01;
blk.Tf.Free = false;
blk
blk =
where r,y are the controller inputs and Kp, Kd, b, c are tunable gains.
1-400
ltiblock.pid2
where r,y are the controller inputs and Kp, Ki, b are tunable gains.
Type "showBlockValue(blk)" to see the current value and "get(blk)" to
blk takes initial parameter values from sys.
Tips
You can modify the PID structure by fixing or freeing any of the
parameters. For example, blk.Tf.Free = false fixes Tf to its
current value.
To convert a ltiblock.pid2 parametric model to a numeric
(nontunable) model object, use model commands such as tf or ss.
You can also use getValue to obtain the current value of a tunable
model.
See Also
How To
1-401
ltiblock.pid2
1-402
ltiblock.ss
Purpose
Syntax
blk
blk
blk
blk
Description
=
=
=
=
ltiblock.ss(name,Nx,Ny,Nu)
ltiblock.ss(name,Nx,Ny,Nu,Ts)
ltiblock.ss(name,sys)
ltiblock.ss(...,Astruct)
Construction
Input Arguments
name
1-403
ltiblock.ss
Structure of A matrix
'tridiag'
A is tridiagonal. In tridiagonal
form, A has free elements only
parameter).
'companion'
A is in companion form.
1-404
ltiblock.ss
String
Structure of A matrix
in the rightmost column of the
A matrix. See canon for more
information.
Tips
Properties
a, b, c, d
1-405
ltiblock.ss
The following fields of blk.a, blk.b, blk.c, and blk.d are used when
you tune blk using hinfstruct:
Field
Description
Value
Free
1-406
ltiblock.ss
Field
Description
Maximum
StateName
1-407
ltiblock.ss
StateUnit
State units. Use StateUnit to keep track of the units each state is
expressed in. For first-order models, set StateUnit to a string. For
models with two or more states, set StateUnit to a cell array of strings.
StateUnit has no effect on system behavior.
Default: Empty string '' for all states
Ts
1-408
ltiblock.ss
'days'
'weeks'
'months'
'years'
Changing this property changes the overall system behavior. Use
chgTimeUnit to convert between time units without modifying system
behavior.
Default: 'seconds'
InputName
1-409
ltiblock.ss
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-410
ltiblock.ss
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
1-411
ltiblock.ss
Name
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
Examples
1-412
ltiblock.ss
See Also
How To
1-413
ltiblock.tf
Purpose
Syntax
blk = ltiblock.tf(name,Nz,Np)
blk = ltiblock.tf(name,Nz,Np,Ts)
blk = ltiblock.tf(name,sys)
Description
Model object for creating tunable SISO transfer function models of fixed
order. ltiblock.tf lets you parametrize a transfer function of a given
orderfor parameter studies or for automatic tuning with Robust Control
Toolbox tuning commands such as systune or looptune.
ltiblock.tf is part of the Control Design Block family of parametric
models. Other Control Design Blocks includeltiblock.pid,
ltiblock.ss, and ltiblock.gain.
Construction
transfer function:
blk =
am sm + am1 sm1 + + a1 s + a0
sn + bn1 sn1 + + b1 s + b0
Input Arguments
name
1-414
ltiblock.tf
Tips
Properties
num, den
1-415
ltiblock.tf
Field
Description
Value
Free
1-416
ltiblock.tf
Field
Description
Minimum
Maximum
Ts
1-417
ltiblock.tf
1-418
ltiblock.tf
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-419
ltiblock.tf
OutputName
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
1-420
ltiblock.tf
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
Examples
Create a parametric SISO transfer function with two zeros, four poles,
and at least one integrator.
A transfer function with an integrator includes a factor of 1/s.
Therefore, to ensure that a parametrized transfer function has at least
1-421
ltiblock.tf
See Also
How To
1-422
ltiview
Purpose
Syntax
ltiview
ltiview(sys1,sys2,...,sysn)
ltiview(plottype,sys)
ltiview(plottype,sys,extras)
ltiview('clear',viewers)
ltiview('current',sys1,sys2,...,sysn,viewers)
ltiview(plottype,sys1,sys2,...sysN)
ltiview(plottype,sys1,PlotStyle1,sys2,PlotStyle2,...)
ltiview(plottype,sys1,sys2,...sysN,extras)
Description
response type indicated by plottype for the LTI model sys. The string
plottype can be any one of the following:
'step'
'impulse'
'initial'
'lsim'
'pzmap'
'bode'
'nyquist'
'nichols'
'sigma'
1-423
ltiview
or,
plottype can be a cell vector containing up to six of these plot types.
For example,
ltiview({'step';'nyquist'},sys)
displays the plots of both of these response types for a given system sys.
ltiview(plottype,sys,extras) allows the additional input
arguments supported by the various LTI model response functions to be
passed to the ltiview command.
extras is one or more input arguments as specified by the function
named in plottype. These arguments may be required or optional,
depending on the type of LTI response. For example, if plottype is
'step' then extras may be the desired final time, Tfinal, as shown
below.
ltiview('step',sys,Tfinal)
1-424
ltiview
initializes the viewer with specified plot styles. See the individual
reference pages of the LTI response functions for more information
on specifying plot styles.
ltiview(plottype,sys1,sys2,...sysN,extras) initializes the viewer
for multiple models using the extras input arguments.
See Also
Related
Examples
1-425
lyap
Purpose
Syntax
lyap
X = lyap(A,Q)
X = lyap(A,B,C)
X = lyap(A,Q,[],E)
Description
lyap solves the special and general forms of the Lyapunov equation.
AX + XAT + Q = 0
where A and Q represent square matrices of identical sizes. If Q is a
symmetric matrix, the solution X is also a symmetric matrix.
X = lyap(A,B,C) solves the Sylvester equation
AX + XB + C = 0
The matrices A, B, and C must have compatible dimensions but need
not be square.
X = lyap(A,Q,[],E) solves the generalized Lyapunov equation
AXET + EXAT + Q = 0
where Q is a symmetric matrix. You must use empty square brackets
[] for this function. If you place any values inside the brackets, the
function errors out.
Algorithms
1-426
lyap
Limitations
i + j 0
Examples
Example 1
Solve Lyapunov Equation
Solve the Lyapunov equation
AX + XAT + Q = 0
where
2
1
A=
3 4
3 1
Q=
1 1
-3.8333
3.0000
1-427
lyap
Example 2
Solve Sylvester Equation
Solve the Sylvester equation
AX + XB + C = 0
where
A=5
A
B
C
X
=
=
=
=
4 3
B=
4 3
C = [ 2 1]
5;
[4 3; 4 3];
[2 1];
lyap(A,B,C)
References
-0.0500
[1] Bartels, R.H. and G.W. Stewart, "Solution of the Matrix Equation
AX + XB = C," Comm. of the ACM, Vol. 15, No. 9, 1972.
[2] Barraud, A.Y., A numerical algorithm to solve A XA - X = Q, IEEE
Trans. Auto. Contr., AC-22, pp. 883885, 1977.
1-428
lyap
See Also
covar | dlyap
1-429
lyapchol
Purpose
Syntax
R = lyapchol(A,B)
X = lyapchol(A,B,E)
Description
All eigenvalues of matrix A must lie in the open left half-plane for R
to exist.
X = lyapchol(A,B,E) computes a Cholesky factorization X = R'*R of
X solving the generalized Lyapunov equation:
A*X*E' + E*X*A' + B*B' = 0
All generalized eigenvalues of (A,E) must lie in the open left half-plane
for R to exist.
Algorithms
References
[1] Bartels, R.H. and G.W. Stewart, "Solution of the Matrix Equation
AX + XB = C," Comm. of the ACM, Vol. 15, No. 9, 1972.
[2] Hammarling, S.J., Numerical solution of the stable, non-negative
definite Lyapunov equation, IMA J. Num. Anal., Vol. 2, pp. 303-325,
1982.
[3] Penzl, T., Numerical solution of generalized Lyapunov equations,
Advances in Comp. Math., Vol. 8, pp. 33-48, 1998.
See Also
1-430
lyap | dlyapchol
mag2db
Purpose
Syntax
ydb = mag2db(y)
Description
ydb = mag2db(y) returns the corresponding decibel (dB) value ydb for a
See Also
db2mag
1-431
margin
Purpose
Syntax
[Gm,Pm,Wgm,Wpm] = margin(sys)
[Gm,Pm,Wgm,Wpm] = margin(mag,phase,w)
margin(sys)
Description
margin calculates the minimum gain margin, Gm, phase margin, Pm,
and associated frequencies Wgm and Wpm of SISO open-loop models. The
gain and phase margin of a system sys indicates the relative stability
of the closed-loop system formed by applying unit negative feedback to
sys, as in the following illustration.
+
-
sys
1-432
margin
margin returns the smallest gain and phase margins and corresponding
frequencies.
The phase margin Pm is in degrees. The gain margin Gm is an absolute
magnitude. You can compute the gain margin in dB by
Gm_dB = 20*log10(Gm)
[Gm,Pm,Wgm,Wpm] = margin(mag,phase,w) derives the gain and
Examples
1-433
margin
Pm =
13.5711
Wgm =
5.4374
Wpm =
4.3544
1-434
margin
Solid vertical lines mark the gain margin and phase margin. The
dashed vertical lines indicate the locations of Wpm, the frequency where
the phase margin is measured, and Wgm, the frequency where the gain
margin is measured.
Algorithms
The phase margin is computed using H theory, and the gain margin
by solving H ( j ) = H ( j ) for the frequency .
See Also
bode | ltiview
1-435
minreal
Purpose
Syntax
sysr = minreal(sys)
sysr = minreal(sys,tol)
[sysr,u] = minreal(sys,tol)
... = minreal(sys,tol,false)
... = minreal(sys,[],false)
Description
Examples
The commands
g = zpk([],1,1);
h = tf([2 1],[1 0]);
cloop = inv(1+g*h) * g
1-436
minreal
(s-1) (s^2 + s + 1)
Continuous-time zero/pole/gain model.
Algorithms
See Also
1-437
modred
Purpose
Syntax
rsys = modred(sys,elim)
rsys = modred(sys,elim,'method')
Description
elim = (g<1e-8)
1-438
modred
Examples
h(s) =
s3 + 11s2 + 36 s + 26
s4 + 14.6 s3 + 74.96 s2 + 153.7s + 99.65
0.0095
0.0006
0.0000
The last three diagonal entries of the balanced gramians are relatively
small. Eliminate these three least-contributing states with modred
using both matched DC gain and direct deletion methods.
hmdc = modred(hb,2:4,'MatchDC');
hdel = modred(hb,2:4,'Truncate');
Both hmdc and hdel are first-order models. Compare their Bode
responses against that of the original model h(s).
bodeplot(h,'-',hmdc,'x',hdel,'*')
1-439
modred
1-440
modred
While hdel accurately reflects the transient behavior, only hmdc gives
the true steady-state response.
Algorithms
x = Ax + By
y = Cx + Du
the state vector is partitioned into x1, to be kept, and x2, to be eliminated.
1-441
modred
x1 A11 A12 x1 B1
x = A
+ u
2 21 A22 x2 B2
y = [C1 C2 ] x + Du
Next, the derivative of x2 is set to zero and the resulting equation is
solved for x1. The reduced-order model is given by
x2[ n + 1] = x2[ n]
Limitations
See Also
balreal | minreal
1-442
modsep
Purpose
Syntax
[H,H0] = modsep(G,N,REGIONFCN)
MODSEP(G,N,REGIONFCN,PARAM1,...)
Description
G(s) = H 0 +
N
Hj(s)
j =1
G can be any LTI model created with ss, tf, or zpk, and N is the number
of regions used in the decomposition. modsep packs the submodels Hj
into an LTI array H and returns the static gain H0 separately. Use
H(:,:,j) to retrieve the submodel Hj(s).
that assigns a region index IR between 1 and N to a given pole p. You can
specify this function as a string or a function handle, and use the syntax
MODSEP(G,N,REGIONFCN,PARAM1,...) to pass extra input arguments:
IR = REGIONFCN(p,PARAM1,...)
Examples
= modsep(G,2,@udsep)
1-443
modsep
See Also
1-444
stabsep
H2 = H(:,:,2);
nblocks
Purpose
Syntax
N = nblocks(M)
Description
Input
Arguments
Output
Arguments
Examples
F s
n2
s2 2n n2
1-445
nblocks
nblocks(F)
F s
1
2
2
n
1
n
nblocks(F)
1-446
nblocks
See Also
How To
1-447
ndims
Purpose
Syntax
n = ndims(sys)
Description
outputs, and one for inputs). A model array has 2 + p dimensions, where
p 2 is the number of array dimensions. For example, a 2-by-3-by-4
array of models has 2 + 3 = 5 dimensions.
ndims(sys) = length(size(sys))
Examples
sys = rss(3,1,1,3);
ndims(sys)
ans =
4
ndims returns 4 for this 3-by-1 array of SISO models.
See Also
1-448
size
ngrid
Purpose
Syntax
ngrid
Description
ngrid superimposes Nichols chart grid lines over the Nichols frequency
response of a SISO LTI system. The range of the Nichols grid lines is
set to encompass the entire Nichols frequency response.
H
1+ H
is the corresponding value of the closed-loop frequency response
assuming unit negative feedback.
If the current axis is empty, ngrid generates a new Nichols chart grid
in the region 40 dB to 40 dB in magnitude and 360 degrees to 0
degrees in phase. If the current axis does not contain a SISO Nichols
frequency response, ngrid returns a warning.
Examples
Plot the Nichols response with Nichols grid lines for the system.
H (s) =
4 s4 + 48 s3 18 s2 + 250 s + 600
s4 + 30 s3 + 282s2 + 525s + 60
Type
H = tf([-4 48 -18 250 600],[1 30 282 525 60])
1-449
ngrid
Type
nichols(H)
ngrid
See Also
1-450
nichols
nichols
Purpose
Syntax
nichols(sys)
nichols(sys)
nichols(sys,w)
nichols(sys1,sys2,...,sysN)
nichols(sys1,sys2,...,sysN,w)
nichols(sys1,'PlotStyle1',...,sysN,'PlotStyleN')
[mag,phase,w] = nichols(sys)
[mag,phase] = nichols(sys,w)
[mag,phase,w] = nichols(sys)
[mag,phase] = nichols(sys,w)
Description
1-451
nichols
returns the magnitude and phase (in degrees) of the frequency response
at the frequencies w (in rad/TimeUnit). The outputs mag and phase are
3-D arrays similar to those produced by bode (see the bode reference
page). They have dimensions
(number of outputs) (number of inputs) (length of w)
Tips
You 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.
Examples
H (s) =
4 s4 + 48 s3 18 s2 + 250 s + 600
s4 + 30 s3 + 282s2 + 525s + 60
1-452
nichols
The right-click menu for Nichols charts includes the Tight option under
Zoom. You can use this to clip unbounded branches of the Nichols chart.
Algorithms
See bode.
See Also
1-453
nicholsoptions
Purpose
Syntax
P = nicholsoptions
P = nicholsoptions('cstprefs')
Description
with default values set. You can use these options to customize the
Nichols plot appearance from the command line.
P = nicholsoptions('cstprefs') initializes the plot options with the
1-454
Option
Description
TickLabel
Grid
XlimMode, YlimMode
Limit modes
Xlim, Ylim
Axes limits
IOGrouping
InputLabels, OutputLabels
InputVisible, OutputVisible
nicholsoptions
Option
Description
FreqUnits
1-455
nicholsoptions
Option
Description
'cycles/year'
Default: 'rad/s'
You can also specify 'auto'
which uses frequency units
rad/TimeUnit relative to system
time units specified in the
TimeUnit property. For multiple
systems with different time units,
the units of the first system are
used.
1-456
MagLowerLimMode
MagLowerLim
PhaseUnits
Phase units
Specified as one of the following
strings: 'deg' | 'rad'
Default: 'deg'
PhaseWrapping
PhaseMatching
nicholsoptions
Examples
Option
Description
PhaseMatchingFreq
PhaseMatchingValue
In this example, you set the phase units and enable the grid option
for the Nichols plot.
P = nicholsoptions; % Set phase units to radians and grid to on in options
P.PhaseUnits = 'rad';
P.Grid = 'on'; % Create plot with the options specified by P
h = nicholsplot(tf(1,[1,.2,1,0]),P);
The following Nichols plot is created, with the phase units in radians
and the grid enabled.
1-457
nicholsoptions
See Also
1-458
nicholsplot
Purpose
Syntax
h = nicholsplot(sys)
nicholsplot(sys,{wmin,wmax})
nicholsplot(sys,w)
nicholsplot(sys1,sys2,...,w)
nicholsplot(AX,...)
nicholsplot(..., plotoptions)
Description
Type
help nicholsoptions
1-459
nicholsplot
Tips
You 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.
Examples
Generate Nichols plot and use plot handle to change frequency units
to Hz
sys = rss(5);
h = nicholsplot(sys);
% Change units to Hz
setoptions(h,'FreqUnits','Hz');
See Also
1-460
nmodels
Purpose
Syntax
N = nmodels(sysarray)
Description
Input
Arguments
Output
Arguments
Examples
See Also
ndims | size
1-461
norm
Purpose
Syntax
n = norm(sys)
n = norm(sys,2)
n = norm(sys,inf)
[n,fpeak] = norm(sys,inf)
[...] = norm(sys,inf,tol)
Description
norm to tol.
Input
Arguments
sys
Output
Arguments
1-462
norm
Definitions
H2 norm
The H2 norm of a stable continuous-time system with transfer function
H(s), is given by:
1
2
Trace H ( j)
H ( j ) d .
1
Trace H (e j ) H H (e j ) d .
2
2
E ( w(t)w( )T ) = ( t ) I .
H-infinity norm
The H norm (also called the L norm) of a SISO linear system is the
peak gain of the frequency response. For a MIMO system, the H
norm is the peak gain across all input/output channels. Thus, for a
continuous-time system H(s), the H norm is given by:
1-463
norm
H ( s)
= max H ( j )
(SISO)
H ( s)
= max max ( H ( j ) )
(MIMO)
( )
H ( z)
= max H e j
[0, ]
H ( z)
= max max H e j
[0, ]
( ( ))
(SISO)
(MIMO)
The H norm is infinite if sys has poles on the imaginary axis (in
continuous time), or on the unit circle (in discrete time).
Examples
H ( z) =
1-464
norm
[ninf,fpeak] = norm(H,inf)
1-465
norm
1-466
norm
Algorithms
(peak gain) using the SLICOT library. For more information about the
SLICOT library, see http://slicot.org.
References
[1] Bruisma, N.A. and M. Steinbuch, "A Fast Algorithm to Compute the
H-Norm of a Transfer Function Matrix," System Control Letters, 14
(1990), pp. 287-293.
See Also
freqresp | sigma
1-467
nyquist
Purpose
Syntax
nyquist(sys)
nyquist(sys,w)
nyquist(sys1,sys2,...,sysN)
nyquist(sys1,sys2,...,sysN,w)
nyquist(sys1,'PlotStyle1',...,sysN,'PlotStyleN')
[re,im,w] = nyquist(sys)
[re,im] = nyquist(sys,w)
[re,im,w,sdre,sdim] = nyquist(sys)
Description
produces a Nyquist plot on the screen. Nyquist plots are used to analyze
system properties including gain margin, phase margin, and stability.
nyquist(sys) creates a Nyquist plot of a dynamic system sys. This
1-468
nyquist
Tips
You 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.
Arguments
re(1, 1, k) = Re ( h( jk ) )
im(1, 1, k) = Im ( h( jwk ) )
For MIMO systems with transfer function H(s), re(:,:,k) and
im(:,:,k) give the real and imaginary parts of H(jk) (both arrays with
as many rows as outputs and as many columns as inputs). Thus,
re (i, j, k) = Re ( hij ( jk ) )
im (i, j, k) = Im ( hij ( jk ) )
where hij is the transfer function from input j to output i.
Examples
Example 1
Nyquist Plot of Dynamic System
Plot the Nyquist response of the system
1-469
nyquist
H (s) =
2s2 + 5s + 1
s2 + 2s + 3
The nyquist function has support for M-circles, which are the contours
of the constant closed-loop magnitude. M-circles are defined as the
locus of complex numbers where
T ( j ) =
G( j )
1 + G( j )
1-470
nyquist
at the MATLAB prompt. This figure shows the M circles for transfer
function H.
You have two zoom options available from the right-click menu that
apply specifically to Nyquist plots:
Tight Clips unbounded branches of the Nyquist plot, but still
includes the critical point (-1, 0)
On (-1,0) Zooms around the critical point (-1,0)
1-471
nyquist
Also, click anywhere on the curve to activate data markers that display
the real and imaginary values at a given frequency. This figure shows
the nyquist plot with a data marker.
Example 2
Compute the standard deviation of the real and imaginary parts of
frequency response of an identified model. Use this data to create a 3
plot of the response uncertainty.
Identify a transfer function model based on data. Obtain the standard
deviation data for the real and imaginary parts of the frequency
response.
load iddata2 z2;
sys_p = tfest(z2,2);
w = linspace(-10*pi,10*pi,512);
[re, im, ~, sdre, sdim] = nyquist(sys_p,w);
1-472
nyquist
Algorithms
See bode.
See Also
1-473
nyquistoptions
Purpose
Syntax
P = nyquistoptions
P = nyquistoptions('cstprefs')
Description
can use these options to customize the Nyquist plot appearance using
the command line.
P = nyquistoptions('cstprefs') initializes the plot options with the
1-474
Option
Description
TickLabel
Grid
XlimMode, YlimMode
Limit modes
Xlim, Ylim
Axes limits
IOGrouping
InputLabels,
OutputLabels
InputVisible,
OutputVisible
nyquistoptions
Option
Description
FreqUnits
1-475
nyquistoptions
Option
Description
'cycles/year'
Default: 'rad/s'
You can also specify 'auto' which uses frequency units
rad/TimeUnit relative to system time units specified in the
TimeUnit property. For multiple systems with different time
units, the units of the first system are used.
MagUnits
Magnitude units
Specified as one of the following strings: 'dB' | 'abs'
Default: 'dB'
PhaseUnits
Phase units
Specified as one of the following strings: 'deg' | 'rad'
Default: 'deg'
ShowFullContour
ConfidenceRegionNumberSD
Number of standard deviations to use to plotting the response
confidence region (identified models only).
Default: 1.
ConfidenceRegionDisplaySpacing
The frequency spacing of confidence ellipses. For identified models
only.
Default: 5, which means the confidence ellipses are shown at
every 5th frequency sample.
Examples
This example shows how to create a Nyquist plot displaying the full
contour (the response for both positive and negative frequencies).
P = nyquistoptions;
P.ShowFullContour = 'on';
h = nyquistplot(tf(1,[1,.2,1]),P);
See Also
1-476
nyquistplot
Purpose
Syntax
h = nyquistplot(sys)
nyquistplot(sys,{wmin,wmax})
nyquistplot(sys,w)
nyquistplot(sys1,sys2,...,w)
nyquistplot(AX,...)
nyquistplot(..., plotoptions)
Description
1-477
nyquistplot
Tips
You 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.
Examples
Example 1
Customize Nyquist Plot Frequency Units
Plot the Nyquist frequency response and change the units to rad/s.
sys = rss(5);
h = nyquistplot(sys);
% Change units to radians per second.
setoptions(h,'FreqUnits','rad/s');
Example 2
Compare the frequency responses of identified state-space models of
order 2 and 6 along with their 1-std confidence regions rendered at
every 50th frequency sample.
load iddata1
sys1 = n4sid(z1, 2) % discrete-time IDSS model of order 2
sys2 = n4sid(z1, 6) % discrete-time IDSS model of order 6
Both models produce about 76% fit to data. However, sys2 shows
higher uncertainty in its frequency response, especially close to Nyquist
frequency as shown by the plot:
w = linspace(10,10*pi,256);
h = nyquistplot(sys1,sys2,w);
setoptions(h,'ConfidenceRegionDisplaySpacing',50,'ShowFullContour','off');
1-478
nyquistplot
See Also
1-479
obsv
Purpose
Observability matrix
Syntax
obsv(A,C)
Ob = obsv(sys)
Description
C
CA
Ob = CA
:
n1
CA
Examples
1
-2
1
0
0
1
C =
is observable. Type
1-480
obsv
Ob = obsv(A,C);
% Number of unobservable states
unob = length(A)-rank(Ob)
Tips
See Also
obsvf
1-481
obsvf
Purpose
Syntax
[Abar,Bbar,Cbar,T,k] = obsvf(A,B,C)
obsvf(A,B,C,tol)
Description
A = TAT T , B = TB, C = CT T
where T is unitary and the transformed system has a staircase form
with the unobservable modes, if any, in the upper left corner.
A12
B
, B = no , C = [0 Co ]
Ao
Bo
A
A = no
0
where (Co, Ao) is observable, and the eigenvalues of Ano are the
unobservable modes.
[Abar,Bbar,Cbar,T,k] = obsvf(A,B,C) decomposes the state-space
system with matrices A, B, and C into the observability staircase
form Abar, Bbar, and Cbar, as described above. T is the similarity
transformation matrix and k is a vector of length n, where n is the
number of states in A. Each entry of k represents the number of
Examples
1-482
obsvf
-2
1
1
-1
-1
1
0
0
1
B =
C =
by typing
[Abar,Bbar,Cbar,T,k] = obsvf(A,B,C)
Abar =
1
1
4
-2
Bbar =
1
1
1
-1
Cbar =
1
0
0
1
T =
1
0
0
1
k =
2
0
Algorithms
References
See Also
ctrbf | obsv
1-483
ord2
Purpose
Syntax
[A,B,C,D] = ord2(wn,z)
[num,den] = ord2(wn,z)
Description
h(s) =
1
2
s + 2n s + n2
given the natural frequency wn (n) and damping factor z (). Use ss to
turn this description into a state-space object.
[num,den] = ord2(wn,z) returns the numerator and denominator of
the second-order transfer function. Use tf to form the corresponding
transfer function object.
Examples
See Also
1-484
rss | ss | tf
order
Purpose
Syntax
NS = order(sys)
Description
Caveat
See Also
pole | balred
1-485
pade
Purpose
Syntax
[num,den] = pade(T,N)
sysx = pade(sys,N)
sysx = pade(sys,NU,NY,NINT)
Description
are useful to model time delay effects such as transport and computation
delays within the context of continuous-time systems. The Laplace
transform of a time delay of T seconds is exp(sT). This exponential
transfer function is approximated by a rational transfer function using
Pad approximation formulas [1].
[num,den] = pade(T,N) returns the Pad approximation of order N
plots the step and phase responses of the Nth-order Pad approximation
and compares them with the exact responses of the model with I/O delay
T. Note that the Pad approximation has unit gain at all frequencies.
sysx = pade(sys,N) produces a delay-free approximation sysx of
the continuous delay system sys. All delays are replaced by their
Nth-order Pad approximation. See Models with Time Delays for more
1-486
pade
NINT is the approximation order for I/O delays (TF or ZPK models) or
internal delays (state-space models)
You can use scalar values for NU, NY, or NINT to specify a uniform
approximation order. You can also set some entries of NU, NY, or NINT to
Inf to prevent approximation of the corresponding delays.
Examples
1-487
pade
Limitations
References
See Also
1-488
pade
How To
Time-Delay Approximation
1-489
parallel
Purpose
Syntax
parallel
sys = parallel(sys1,sys2)
sys = parallel(sys1,sys2,inp1,inp2,out1,out2)
sys = parallel(sys1,sys2,'name')
Description
any type of model. The two systems must be either both continuous or
both discrete with identical sample time. Static gains are neutral and
can be specified as regular matrices.
sys = parallel(sys1,sys2) forms the basic parallel connection
1-490
parallel
The vectors inp1 and inp2 contain indexes into the input channels of
sys1 and sys2, respectively, and define the input channels u1 and u2
in the diagram. Similarly, the vectors out1 and out2 contain indexes
into the outputs of these two systems and define the output channels
y1 and y2 in the diagram. The resulting model sys has [v1 ; u ; v2] as
inputs and [z1 ; y ; z2] as outputs.
sys = parallel(sys1,sys2,'name') connects sys1 and sys2 by
matching I/O names. You must specify all I/O names of sys1 and sys2.
The matching names appear in sys in the same order as in sys1. For
example, the following specification:
sys1 = ss(eye(3),'InputName',{'C','B','A'},'OutputName',{'Z','Y','X'});
sys2 = ss(eye(3),'InputName',{'A','C','B'},'OutputName',{'X','Y','Z'});
parallel(sys1,sys2,'name')
C
1
1
0
B
1
1
0
A
0
0
2
1-491
parallel
Static gain.
Examples
See Also
1-492
permute
Purpose
Syntax
newarray = permute(sysarray,order)
Description
Input
Arguments
model array
vector
Output
Arguments
Examples
1-493
permute
size(newarr)
3x2 array of state-space models.
Each model has 2 outputs, 2 inputs, and 2 states.
The input and output dimensions of the model array remain unchanged.
See Also
1-494
pid
Purpose
Syntax
C
C
C
C
C
C
C
C
Description
=
=
=
=
=
=
=
=
pid(Kp,Ki,Kd,Tf)
pid(Kp,Ki,Kd,Tf,Ts)
pid(sys)
pid(Kp)
pid(Kp,Ki)
pid(Kp,Ki,Kd)
pid(...,Name,Value)
pid
C = Kp +
Ki
Kds
+
.
s Tf s + 1
This representation is in parallel form. If all of Kp, Ki, Kd, and Tf are
real, then the resulting C is a pid controller object. If one or more
of these coefficients is tunable (realp or genmat), then C is a tunable
generalized state-space (genss) model object.
C = pid(Kp,Ki,Kd,Tf,Ts) creates a discrete-time PID controller with
C = K p + K i IF ( z ) +
Kd
.
Tf + DF ( z )
IF(z) and DF(z) are the discrete integrator formulas for the integrator
and derivative filter. By default, IF(z) = DF(z) = Tsz/(z 1). To choose
different discrete integrator formulas, use the IFormula and DFormula
properties. (See Properties on page 1-500 for more information about
IFormula and DFormula). If DFormula = 'ForwardEuler' (the default
value) and Tf 0, then Ts and Tf must satisfy Tf > Ts/2. This
requirement ensures a stable derivative filter pole.
1-495
pid
controller object.
C = pid(Kp) creates a continuous-time proportional (P) controller with
Ki = 0, Kd = 0, and Tf = 0.
C = pid(Kp,Ki) creates a proportional and integral (PI) controller with
Kd = 0 and Tf = 0.
C = pid(Kp,Ki,Kd) creates a proportional, integral, and derivative
(PID) controller with Tf = 0.
C = pid(...,Name,Value) creates a controller or converts a dynamic
system to a pid controller object with additional options specified by one
or more Name,Value pair arguments.
C = pid creates a P controller with Kp = 1.
Tips
Use pid either to create a pid controller object from known PID
gains and filter time constant, or to convert a dynamic system model
to a pid object.
To deisgn a PID controller for a particular plant, use pidtune or
pidtool.
Create arrays of pid controller objects by:
1-496
pid
Td s
1 1
C = K p 1 +
+
.
Ti s Td
s + 1
N
Use the c2d command. c2d computes new parameter values for
the discretized controller. The discrete integrator formulas of the
discretized controller depend upon the c2d discretization method
you use, as shown in the following table.
c2d Discretization
IFormula
DFormula
'zoh'
ForwardEuler
ForwardEuler
'foh'
Trapezoidal
Trapezoidal
'tustin'
Trapezoidal
Trapezoidal
'impulse'
ForwardEuler
ForwardEuler
'matched'
ForwardEuler
ForwardEuler
Method
Input
Arguments
Kp
Proportional gain.
Kp can be:
1-497
pid
Integral gain.
Ki can be:
A real and finite value.
An array of real and finite values.
A tunable parameter (realp).
A tunable generalized matrix (genmat), such as a gain surface for
gain-scheduled tuning, created using gainsurf (requires Robust
Control Toolbox software).
When Ki = 0, the controller has no integral action.
Default: 0
Kd
Derivative gain.
Kd can be:
A real and finite value.
An array of real and finite values.
A tunable parameter (realp).
1-498
pid
Sampling time.
To create a discrete-time pid controller, provide a positive real
value (Ts > 0). pid does not support discrete-time controller with
undetermined sample time (Ts = -1).
Ts must be a scalar value. In an array of pid controllers, each controller
must have the same Ts.
sys
1-499
pid
Output
Arguments
Properties
1-500
pid
Tf
C = K p + K i IF ( z ) +
Kd
.
Tf + DF ( z )
Ts
.
z 1
This formula is best for small sampling time, where the Nyquist limit
is large compared to the bandwidth of the controller. For larger
sampling time, the ForwardEuler formula can result in instability,
even when discretizing a system that is stable in continuous time.
'ForwardEuler' IF(z) =
'BackwardEuler' IF(z) =
Ts z
.
z 1
Ts z + 1
.
2 z 1
An advantage of the Trapezoidal formula is that discretizing a
stable continuous-time system using this formula always yields a
stable discrete-time result. Of all available integration formulas,
the Trapezoidal formula yields the closest match between
'Trapezoidal' IF(z) =
1-501
pid
C = K p + K i IF ( z ) +
Kd
.
Tf + DF ( z )
Ts
.
z 1
This formula is best for small sampling time, where the Nyquist limit
is large compared to the bandwidth of the controller. For larger
sampling time, the ForwardEuler formula can result in instability,
even when discretizing a system that is stable in continuous time.
'ForwardEuler' DF(z) =
'BackwardEuler' DF(z) =
Ts z
.
z 1
Ts z + 1
.
2 z 1
An advantage of the Trapezoidal formula is that discretizing a
stable continuous-time system using this formula always yields a
stable discrete-time result. Of all available integration formulas,
the Trapezoidal formula yields the closest match between
'Trapezoidal' DF(z) =
1-502
pid
1-503
pid
1-504
pid
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-505
pid
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
1-506
pid
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
SamplingGrid
1-507
pid
each model in the array. This information appears when you display
or plot the model array. Use this information to trace results back to
the independent variables.
Set the field names of the data structure to the names of the sampling
variables. Set the field values to the sampled variable values associated
with each model in the array. All sampling variables should be numeric
and scalar valued, and all arrays of sampled values should match the
dimensions of the model array.
For example, suppose you create a 11-by-1 array of linear models,
sysarr, by taking snapshots of a linear time-varying system at times
t = 0:10. The following code stores the time samples with the linear
models.
sysarr.SamplingGrid = struct('time',0:10)
When you display M, each entry in the array includes the corresponding
zeta and w values.
M
M(:,:,1,1) [zeta=0.3, w=5] =
25
-------------s^2 + 3 s + 25
1-508
pid
---------------s^2 + 3.5 s + 25
...
Default: []
Examples
C =
s
Kp + Kd * -------Tf*s+1
with Kp = 1, Kd = 3, Tf = 0.5
Continuous-time PDF controller in parallel form.
The display hows the controller type, formula, and parameter values.
Discrete-Time PI Controller
Create a discrete-time PI controller with trapezoidal discretization
formula.
1-509
pid
1-510
pid
Kp = [1 1 1;2 2 2];
Ki = [5:2:9;5:2:9];
pi_array = pid(Kp,Ki,'Ts',0.1,'IFormula','BackwardEuler');
% Standard-form controller
1-511
pid
H ( s) =
3 ( s + 1) ( s + 2 )
s
1-512
pid
The resulting pid object depends upon the discrete integrator formula
you specify for IFormula and DFormula. For example, if you use the
default ForwardEuler for both formulas:
C = pid(sys)
1-513
pid
For this particular sys, you cannot write sys in parallel PID form using
the BackwardEuler formula for DFormula. Doing so would result in
Tf < 0, which is not permitted. In that case, pid returns an error.
Discretize a Continuous-time PID Controller
First, discretize the controller using the 'zoh' method of c2d.
Cc = pid(1,2,3,4) % continuous-time pidf controller
Cd1 = c2d(Cc,0.1,'zoh')
c2d computes new parameters for the discrete-time controller:
Discrete-time PIDF controller in parallel form:
Ts
1
Kp + Ki * ------ + Kd * ----------z-1
Tf+Ts/(z-1)
with Kp = 1, Ki = 2, Kd = 3.0377, Tf = 4.0502, Ts = 0.1
1-514
pid
See Also
Tutorials
How To
1-515
piddata
Purpose
Syntax
[Kp,Ki,Kd,Tf] = piddata(sys)
[Kp,Ki,Kd,Tf,Ts] = piddata(sys)
[Kp,Ki,Kd,Tf,Ts] = piddata(sys, J1,...,JN)
Description
Tips
If sys is not a pid controller object, piddata returns the PID gains
Kp, Ki, Kd and the filter time constant Tf of a parallel-form controller
equivalent to sys.
For discrete-time sys, piddata returns the parameters of an equivalent
parallel-form controller. This controller has discrete integrator formulas
Iformula and Dformula set to ForwardEuler. See the pid reference
page for more information about discrete integrator formulas.
Input
Arguments
sys
Output
Arguments
1-516
Kp
piddata
1-517
piddata
Examples
Extract the proportional, integral, and derivative gains and the filter
time constant from a parallel-form pid controller.
For the following pid object:
sys = pid(1,4,0.3,10);
1-518
piddata
Ki =
0.6667
H ( z) =
( z 0 .5 ) ( z 0 .6 )
( z 1 ) ( z + 0 .8 )
The parameters Kp, Ki, Kd, and Tf are also 2-by-3 arrays.
Use the index input J to extract the parameters of a subset of sys.
[Kp Ki Kd Tf] = piddata(sys,5);
See Also
1-519
pidstd
Purpose
Syntax
C
C
C
C
C
C
C
C
Description
=
=
=
=
=
=
=
=
pidstd(Kp,Ti,Td,N)
pidstd(Kp,Ti,Td,N,Ts)
pidstd(sys)
pidstd(Kp)
pidstd(Kp,Ti)
pidstd(Kp,Ti,Td)
pidstd(...,Name,Value)
pidstd
Td s
1 1
C = K p 1 +
+
.
Ti s Td
s + 1
N
Td
1
C = K p 1 + IF ( z ) +
.
Td
Ti
+ DF ( z )
N
IF(z) and DF(z) are the discrete integrator formulas for the integrator
and derivative filter. By default, IF(z) = DF(z) = Tsz/(z 1). To choose
different discrete integrator formulas, use the IFormula and DFormula
inputs. (See Properties on page 1-525 for more information about
IFormula and DFormula). If DFormula = 'ForwardEuler' (the default
1-520
pidstd
value) and N Inf, then Ts, Td, and N must satisfy Td/N > Ts/2. This
requirement ensures a stable derivative filter pole.
C = pidstd(sys) converts the dynamic system sys to a standard form
pidstd controller object.
C = pidstd(Kp) creates a continuous-time proportional (P) controller
with Ti = Inf, Td = 0, and N = Inf.
C = pidstd(Kp,Ti) creates a proportional and integral (PI) controller
with Td = 0 and N = Inf.
C = pidstd(Kp,Ti,Td) creates a proportional, integral, and derivative
(PID) controller with N = Inf.
C = pidstd(...,Name,Value) creates a controller or converts a
dynamic system to a pidstd controller object with additional options
Tips
1-521
pidstd
C = Kp +
Ki
Kds
+
.
s Tf s + 1
Use the c2d command. c2d computes new parameter values for
the discretized controller. The discrete integrator formulas of the
discretized controller depend upon the c2d discretization method
you use, as shown in the following table.
c2d Discretization
IFormula
DFormula
'zoh'
ForwardEuler
ForwardEuler
'foh'
Trapezoidal
Trapezoidal
'tustin'
Trapezoidal
Trapezoidal
'impulse'
ForwardEuler
ForwardEuler
'matched'
ForwardEuler
ForwardEuler
Method
1-522
pidstd
Input
Arguments
Kp
Proportional gain.
Kp must be a real and finite value.
For an array of pidstd controllers, Kp must be an array of real and
finite values.
Default: 1
Ti
Integral time.
Ti must be a real and positive value. When Ti = Inf, the controller
has no integral action.
For an array of pidstd controllers, Ti must be an array of real and
positive values.
Default: Inf
Td
Derivative time.
Td must be a real, finite, and nonnegative value. When Td = 0, the
controller has no derivative action.
For an array of pidstd controllers, Td must be an array of real, finite,
and nonnegative values.
Default: 0
N
1-523
pidstd
Sampling time.
To create a discrete-time pidstd controller, provide a positive real
value (Ts > 0).pidstd does not support discrete-time controller with
undetermined sample time (Ts = -1).
Ts must be a scalar value. In an array of pidstd controllers, each
controller must have the same Ts.
sys
1-524
pidstd
Output
Arguments
Properties
Integral time. Ti must be real, finite, and greater than or equal to zero.
Td
1-525
pidstd
Td
1
C = K p 1 + IF ( z ) +
.
T
Ti
d + DF z
( )
N
Ts
.
z 1
This formula is best for small sampling time, where the Nyquist limit
is large compared to the bandwidth of the controller. For larger
sampling time, the ForwardEuler formula can result in instability,
even when discretizing a system that is stable in continuous time.
'ForwardEuler' IF(z) =
'BackwardEuler' IF(z) =
Ts z
.
z 1
Ts z + 1
.
2 z 1
An advantage of the Trapezoidal formula is that discretizing a
stable continuous-time system using this formula always yields a
stable discrete-time result. Of all available integration formulas,
the Trapezoidal formula yields the closest match between
frequency-domain properties of the discretized system and the
corresponding continuous-time system.
'Trapezoidal' IF(z) =
1-526
pidstd
Td
1
C = K p 1 + IF ( z ) +
.
T
Ti
d + DF z
( )
N
Ts
.
z 1
This formula is best for small sampling time, where the Nyquist limit
is large compared to the bandwidth of the controller. For larger
sampling time, the ForwardEuler formula can result in instability,
even when discretizing a system that is stable in continuous time.
'ForwardEuler' DF(z) =
'BackwardEuler' DF(z) =
Ts z
.
z 1
Ts z + 1
.
2 z 1
An advantage of the Trapezoidal formula is that discretizing a
stable continuous-time system using this formula always yields a
stable discrete-time result. Of all available integration formulas,
the Trapezoidal formula yields the closest match between
frequency-domain properties of the discretized system and the
corresponding continuous-time system.
'Trapezoidal' DF(z) =
1-527
pidstd
Default: 'ForwardEuler'
InputDelay
1-528
pidstd
'minutes'
'hours'
'days'
'weeks'
'months'
'years'
Changing this property changes the overall system behavior. Use
chgTimeUnit to convert between time units without modifying system
behavior.
Default: 'seconds'
InputName
1-529
pidstd
InputUnit
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-530
pidstd
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
1-531
pidstd
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
SamplingGrid
1-532
pidstd
t = 0:10. The following code stores the time samples with the linear
models.
sysarr.SamplingGrid = struct('time',0:10)
When you display M, each entry in the array includes the corresponding
zeta and w values.
M
M(:,:,1,1) [zeta=0.3, w=5] =
25
-------------s^2 + 3 s + 25
Default: []
Examples
1-533
pidstd
C =
s
Kp * (1 + Td * ------------)
(Td/N)*s+1
with Kp = 1, Td = 3, N = 6
Continuous-time PDF controller in standard form
The display shows the controller type, formula, and coefficient values.
Create a discrete-time PI controller with trapezoidal discretization
formula.
To create a discrete-time controller, set the value of Ts using
Name,Value syntax.
C = pidstd(1,0.5,'Ts',0.1,'IFormula','Trapezoidal') % Ts = 0.1s
1-534
pidstd
1-535
pidstd
H ( s) =
3 ( s + 1) ( s + 2 )
s
1-536
pidstd
For this particular sys, you cannot write sys in standard PID form
using the BackwardEuler formula for the DFormula. Doing so would
result in N < 0, which is not permitted. In that case, pidstd returns
an error.
1-537
pidstd
Similarly, you cannot write sys in standard form using the Trapezoidal
formula for both integrators. Doing so would result in negative Ti and
Td, which also returns an error.
Discretize a continuous-time pidstd controller.
First, discretize the controller using the 'zoh' method of c2d.
Cc = pidstd(1,2,3,4) % continuous-time pidf controller
Cd1 = c2d(Cc,0.1,'zoh')
c2d computes new parameters for the discrete-time controller:
Discrete-time PIDF controller in standard form:
1
Ts
1
Kp * (1 + ---- * ------ + Td * ---------------)
Ti
z-1
(Td/N)+Ts/(z-1)
with Kp = 1, Ti = 2, Td = 3.2044, N = 4, Ts = 0.1
1-538
pidstd
See Also
Tutorials
How To
1-539
pidstddata
Purpose
Syntax
[Kp,Ti,Td,N] = pidstddata(sys)
[Kp,Ti,Td,N,Ts] = pidstddata(sys)
[Kp,Ti,Td,N,Ts] = pidstddata(sys, J1,...,JN)
Description
Kp, integral time Ti, derivative time Td, and filter divisor N of the
standard-form controller represented by the dynamic system sys.
[Kp,Ti,Td,N,Ts] = pidstddata(sys) also returns the sample time
Ts.
[Kp,Ti,Td,N,Ts] = pidstddata(sys, J1,...,JN) extracts the data
for a subset of entries in the array of sys dynamic systems. The indices
J specify the array entries to extract.
Tips
Input
Arguments
sys
Output
Arguments
1-540
Kp
pidstddata
1-541
pidstddata
Examples
Extract the proportional, integral, and derivative gains and the filter
time constant from a standard-form pidstd controller.
For the following pidstd object:
sys = pidstd(1,4,0.3,10);
1-542
pidstddata
Ti =
0.6667
H ( z) =
( z 0 .5 ) ( z 0 .6 )
( z 1 ) ( z + 0 .8 )
The parameters Kp, Ti, Td, and N are also 2-by-3 arrays.
Use the index input J to extract the parameters of a subset of sys.
[Kp Ti Td N] = pidstddata(sys,5);
See Also
1-543
pidtool
Purpose
Syntax
pidtool(sys,type)
pidtool(sys,Cbase)
pidtool(sys)
pidtool
Description
Tips
+
-
sys
The PID Tuner has a default target phase margin of 60 degrees and
automatically tunes the PID gains to balance performance (response
time) and robustness (stability margins). Use the Response time
or Bandwidth and Phase Margin sliders to tune the controllers
performance to your requirements. Increasing performance typically
decreases robustness, and vice versa.
Select response plots from the Response menu to analyze the
controllers performance.
1-544
pidtool
Input
Arguments
sys
1-545
pidtool
String Type
Continuous-Time
Controller
Formula
(parallel form)
Discrete-Time
Controller Formula
(parallel form,
ForwardEuler
integration
method)
'p'
proportional only
'i'
integral only
Kp
Kp
Ki
s
'pi'
'pd'
proportional and
integral
proportional and
derivative
Kp +
Ki
Ki
s
K p + Kds
Ts
z 1
K p + Ki
Ts
z 1
K p + Kd
z 1
Ts
derivative with
first-order filter
on derivative
term
Kp +
Kds
Tf s + 1
K p + Kd
Kp +
Ki
+ Kds
s
K p + Ki
Ts
z 1
+ Kd
z 1
Ts
Kp +
Ki
Kds
+
s Tf s + 1
K p + Ki
Ts
+ Kd
z 1
Tf +
Ts
z 1
'pid' proportional,
integral, and
derivative
'pidf' proportional,
integral, and
derivative with
first-order filter
on derivative
term
1-546
1
Tf +
Ts
z 1
pidtool
When you use the type input, the PID Tuner designs a controller in
parallel form. If you want to design a controller in standard form, Use
the input Cbase instead of type, or select Standard from the Form
menu. For more information about parallel and standard forms, see the
pid and pidstd reference pages.
If sys is a discrete-time model with sampling time Ts, the PID Tuner
designs a discrete-time pid controller using the ForwardEuler discrete
integrator formula. If you want to design a controller having a different
discrete integrator formula, use the input Cbase instead of type or
the Preferences dialog box. For more information about discrete
integrator formulas, see the pid and pidstd reference pages.
Cbase
Examples
1-547
pidtool
Gc = zpk([],[-1 -1 -1],1);
Gd = c2d(Gc,0.1);
pidtool(Gd,'pidf')
The PID Tuner designs a controller for Gd having the same form, type,
and discrete integrator formulas as Cbase. For comparison, you can
display the response plots of Cbase with the response plots of the
designed controller by clicking the Show baseline checkbox on the
PID Tuner GUI.
Algorithms
1-548
pidtool
References
Alternatives
For PID tuning at the command line, use pidtune. pidtune can design
controllers for multiple plants at once.
See Also
Tutorials
How To
1-549
pidtune
Purpose
Syntax
C = pidtune(sys,type)
C = pidtune(sys,C0)
C = pidtune(sys,type,wc)
C = pidtune(sys,C0,wc)
C = pidtune(sys,...,opts)
[C,info] = pidtune(...)
Description
+
-
sys
as the controller C0. If sys and C0 are discrete-time models, C has the
same discrete integrator formulas as C0.
C = pidtune(sys,type,wc) and C = pidtune(sys,C0,wc) specify
Tips
1-550
pidtune
Input
Arguments
sys
1-551
pidtune
StringType
'p'
Proportional only
'i'
Integral only
Continuous-Time
Controller
Formula (parallel
form)
Discrete-Time
Controller
Formula
(parallel form,
ForwardEuler
integration
method)
Kp
Kp
Ki
s
Ki
Ts
z 1
integral
Kp +
Ki
s
K p + Ki
Ts
z 1
K p + Kd
z 1
Ts
derivative
K p + Kds
derivative with
first-order filter on
derivative term
Kp +
Kds
Tf s + 1
K p + Kd
Kp +
Ki
+ Kds
s
K p + Ki
Ts
z 1
+ Kd
z 1
Ts
Kp +
Ki
Kds
+
s Tf s + 1
K p + Ki
Ts
+ Kd
z 1
Tf +
Ts
z 1
'pid' Proportional,
integral, and
derivative
'pidf'Proportional,
integral, and
derivative with
first-order filter on
derivative term
1-552
1
Tf +
Ts
z 1
pidtune
When you use the type input, pidtune designs a controller in parallel
(pid) form. Use the input C0 instead of type if you want to design a
controller in standard (pidstd) form.
If sys is a discrete-time model with sampling time Ts, pidtune
designs a discrete-time controller with the same Ts. The controller has
the ForwardEuler discrete integrator formula for both integral and
derivative actions. Use the input C0 instead of type if you want to
design a controller having a different discrete integrator formula.
C0
pid or pidstd controller specifying properties of the designed controller.
If you provide C0, pidtune:
1-553
pidtune
Option set specifying additional tuning options for the pidtune design
algorithm, such as target phase margin. Use pidtuneOptions to create
opts.
Output
Arguments
Controller type:
If the second argument to pidtune is type, C generally has the
specified type.
If the second argument to pidtune is C0, C generally has the same
type as C0.
In either case, however, where the algorithm can achieve adequate
performance and robustness using a lower-order controller than
specified with type or C0, pidtune returns a C having fewer actions
than specified. For example, C can be a PI controller even though type
is 'pidf'.
Time domain:
C has the same time domain as sys.
If sys is a discrete-time model, C has the same sampling time as sys.
If you specify C0, C has the same Iformula and Dformula as C0. If
no C0 is specified, both Iformula and Dformula are Forward Euler.
See the pid and pidstd reference pages for more information about
Iformula and Dformula.
1-554
pidtune
Examples
sys
s 1 3
1-555
pidtune
info =
Stable: 1
CrossoverFrequency: 0.5205
PhaseMargin: 60.0000
C_pi is a pid controller object that represents a PI controller. The fields
of info show that the tuning algorithm chooses an open-loop crossover
1-556
pidtune
To improve the response time, you can set a higher target crossover
frequency than the result that pidtune automatically selects, 0.52.
Increase the crossover frequency to 1.0.
[C_pi_fast,info] = pidtune(sys,'pi',1.0)
C_pi_fast =
1
Kp + Ki * --s
with Kp = 2.83, Ki = 0.0495
Continuous-time PI controller in parallel form.
info =
Stable: 1
CrossoverFrequency: 1
PhaseMargin: 43.9973
The new controller achieves the higher crossover frequency, but at the
cost of a reduced phase margin.
Compare the closed-loop step response with the two controllers.
T_pi_fast = feedback(C_pi_fast*sys,1);
step(T_pi,T_pi_fast)
axis([0 30 0 1.4])
legend('C\_pi','C\_pi\_fast')
1-557
pidtune
1-558
pidtune
info =
Stable: 1
CrossoverFrequency: 1
PhaseMargin: 60.0000
The fields of info show that the derivative action in the controller
allows the tuning algorithm to design a more aggressive controller that
achieves the target crossover frequency with a good phase margin.
Compare the closed-loop step response and disturbance rejection for
the fast PI and PIDF controllers.
T_pidf_fast = feedback(C_pidf_fast*sys,1);
step(T_pi_fast, T_pidf_fast);
axis([0 30 0 1.4]);
legend('C\_pi\_fast','C\_pidf\_fast');
1-559
pidtune
You can compare the input (load) disturbance rejection of the controlled
system with the fast PI and PIDF controllers. To do so, plot the
response of the closed-loop transfer function from the plant input to
the plant output.
S_pi_fast = feedback(sys,C_pi_fast);
S_pidf_fast = feedback(sys,C_pidf_fast);
step(S_pi_fast,S_pidf_fast);
axis([0 50 0 0.4]);
legend('C\_pi\_fast','C\_pidf\_fast');
This plot shows that the PIDF controller also provides faster
disturbance rejection.
1-560
pidtune
sys
s 1 3
C =
Ts*z
1-561
pidtune
Kp + Ki * -----z-1
with Kp = -0.518, Ki = 10.4, Ts = 0.1
Sample time: 0.1 seconds
Discrete-time PI controller in parallel form.
Algorithms
1-562
pidtune
References
Alternatives
For interactive PID tuning, use the PID Tuner GUI (pidtool). See
PID Controller Design for Fast Reference Tracking for an example of
designing a controller using the PID Tuner GUI.
The PID Tuner GUI cannot design controllers for multiple plants at
once.
See Also
Tutorials
1-563
pidtuneOptions
Purpose
Syntax
opt = pidtuneOptions
opt = pidtuneOptions(Name,Value)
Description
opt = pidtuneOptions returns the default option set for the pidtune
command.
opt = pidtuneOptions(Name,Value) creates an option set with the
Tips
A frd model
A ss model with internal delays that cannot be converted to I/O
delays
Input
Arguments
1-564
pidtuneOptions
Default: 60
NumUnstablePoles
Number of unstable poles in the plant. When your plant is a frd model
or a state-space model with internal delays, you must specify the
number of open-loop unstable poles (if any). Incorrect values might
result in PID controllers that fail to stabilize the real plant. (pidtune
ignores this option for other model types.)
Unstable poles are poles located at:
Re(s) > 0, for continuous-time plants
|z| > 1, for discrete-time plants
A pure integrator in the plant (s = 0) or (|z| > 1) does not count as
an unstable pole for NumUnstablePoles. If your plant is a frd model
of a plant with a pure integrator, for best results, ensure that your
frequency response data covers a low enough frequency to capture the
integrator slope.
Default: 0
Output
Arguments
opt
Examples
See Also
pidtune
1-565
place
Purpose
Syntax
K = place(A,B,p)
[K,prec,message] = place(A,B,p)
Description
x = Ax + Bu
and a vector p of desired self-conjugate closed-loop pole locations, place
computes a gain matrix K such that the state feedback u = Kx places
the closed-loop poles at the locations p. In other words, the eigenvalues
of A BK match the entries of p (up to the ordering).
K = place(A,B,p) places the desired closed-loop poles p by computing
a state-feedback gain matrix K. All the inputs of the plant are assumed
to be control inputs. The length of p must match the row size of A. place
works for multi-input systems and is based on the algorithm from [1].
This algorithm uses the extra degrees of freedom to find a solution that
minimizes the sensitivity of the closed-loop poles to perturbations in
A or B.
[K,prec,message] = place(A,B,p) returns prec, an estimate of
how closely the eigenvalues of A BK match the specified locations p
(prec measures the number of accurate decimal digits in the actual
closed-loop poles). If some nonzero closed-loop pole is more than 10% off
from the desired location, message contains a warning message.
You can also use place for estimator gain selection by transposing the A
matrix and substituting C' for B.
l = place(A',C',p).'
Examples
1-566
place
Algorithms
References
[1] Kautsky, J., N.K. Nichols, and P. Van Dooren, "Robust Pole
Assignment in Linear State Feedback," International Journal of
Control, 41 (1985), pp. 1129-1155.
[2] Laub, A.J. and M. Wette, Algorithms and Software for Pole
Assignment and Observers, UCRL-15646 Rev. 1, EE Dept., Univ. of
Calif., Santa Barbara, CA, Sept. 1984.
See Also
lqr | rlocus
1-567
pole
Purpose
Syntax
pole(sys)
Description
If sys has internal delays, poles are obtained by first setting all internal
delays to zero (creating a zero-order Pad approximation) so that the
system has a finite number of zeros. For some systems, setting delays
to 0 creates singular algebraic loops, which result in either improper or
ill-defined, zero-delay approximations. For these systems, pole returns
an error. This error does not imply a problem with the model sys itself.
Algorithms
For state-space models, the poles are the eigenvalues of the A matrix, or
the generalized eigenvalues of A E in the descriptor case.
For SISO transfer functions or zero-pole-gain models, the poles are
simply the denominator roots (see roots).
For MIMO transfer functions (or zero-pole-gain models), the poles are
computed as the union of the poles for each SISO entry. If some columns
or rows have a common denominator, the roots of this denominator are
counted only once.
Limitations
1/ m
where is the relative machine precision (eps).
See Also
1-568
prescale
Purpose
Syntax
scaledsys = prescale(sys)
scaledsys = prescale(sys,focus)
[scaledsys,info] = prescale(...)
prescale(sys)
Description
and fast dynamics and scaling cannot achieve high accuracy over the
entire dynamic range. By default, prescale attempts to maximize
accuracy in the frequency band with dominant dynamics.
[scaledsys,info] = prescale(...) also returns a structure info
SR
Freqs
RelAcc
The test frequencies lie in the frequency interval focus when specified.
The scaled state-space matrices are
As = TL ATR
Bs = TL B
Cs = CTR
Es = TL ETR
1-569
prescale
For more information on scaling and using the Scaling Tool GUI, see
Scaling State-Space Models.
1-570
prescale
Tips
See Also
ss
1-571
pzmap
Purpose
Syntax
pzmap(sys)
pzmap(sys1,sys2,...,sysN)
[p,z] = pzmap(sys)
Description
function poles and zeros. For MIMO systems, it plots the system poles
and transmission zeros. The poles are plotted as xs and the zeros are
plotted as os.
pzmap(sys1,sys2,...,sysN) creates the pole-zero plot of multiple models
on a single figure. The models can have different numbers of inputs and
outputs and can be a mix of continuous and discrete systems.
You can use the functions sgrid or zgrid to plot lines of constant
damping ratio and natural frequency in the s- or z-plane.
Tips
You 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.
Examples
Example 1
Pole-Zero Plot of Dynamic System
Plot the poles and zeros of the continuous-time system
H ( s) =
2s2 + 5s + 1
s2 + 2s + 3
1-572
pzmap
Example 2
Plot the pzmap for a 2-input-output discrete-time IDSS model.
A = [0.1 0; 0.2 0.9]; B = [.1 .2; 0.1 .02]; C = [10 20; 2 -5]; D = [1 2; 0 1];
sys = idss(A,B,C,D, 'Ts', 0.1);
Algorithms
See Also
1-573
pzplot
Purpose
Syntax
h = pzplot(sys)
pzplot(sys1,sys2,...)
pzplot(AX,...)
pzplot(..., plotoptions)
Description
poles are plotted as xs and the zeros are plotted as os. It also returns
the plot handle h. You can use this handle to customize the plot with
the getoptions and setoptions commands. Type
help pzoptions
model, as in
pzplot(sys1,'r',sys2,'y',sys3,'g')
pzplot(AX,...) plots into the axes with handle AX.
pzplot(..., plotoptions) plots the poles and zeros with the options
specified in plotoptions. Type
help pzoptions
1-574
pzplot
Tips
You 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.
Examples
Use the plot handle to change the color of the plots title.
sys = rss(3,2,2);
h = pzplot(sys);
p = getoptions(h); % Get options for plot.
p.Title.Color = [1,0,0]; % Change title color in options.
setoptions(h,p); % Apply options to plot.
See Also
1-575
pzoptions
Purpose
Syntax
P = pzoptions
P = pzoption('cstprefs')
Description
1-576
Option
Description
TickLabel
Grid
XlimMode, YlimMode
Limit modes
Xlim, Ylim
Axes limits
IOGrouping
InputLabels, OutputLabels
pzoptions
Option
Description
InputVisible, OutputVisible
FreqUnits
1-577
pzoptions
Option
Description
'cycles/week'
'cycles/month'
'cycles/year'
Default: 'rad/s'
You can also specify 'auto'
which uses frequency units
rad/TimeUnit relative to system
time units specified in the
TimeUnit property. For multiple
systems with different time units,
the units of the first system are
used.
TimeUnits
1-578
pzoptions
Option
Description
You can also specify 'auto' which
uses time units specified in the
TimeUnit property of the input
system. For multiple systems
with different time units, the
units of the first system is used.
ConfidenceRegionNumberSD
Examples
In this example, you enable the grid option before creating a plot.
P = pzoptions; % Create set of plot options P
P.Grid = 'on'; % Set the grid to on in options
h = rlocusplot(tf(1,[1,.2,1,0]),P);
The following root locus plot is created with the grid enabled.
1-579
pzoptions
See Also
1-580
realp
Purpose
Syntax
p = realp(paramname,initvalue)
Description
Tips
Input
Arguments
paramname
Output
Arguments
Properties
Name
String containing the name of the realp parameter object. The value
of Name is set by the paramname input argument to realp and cannot
be changed.
Value
1-581
realp
Lower bound for the parameter value. The dimension of the Minimum
property matches the dimension of the Value property.
For matrix-valued parameters, use indexing to specify lower bounds on
individual elements:
p = realp('K',eye(2));
p.Minimum([1 4]) = -5;
Use scalar expansion to set the same lower bound for all matrix
elements:
p.Minimum = -5;
Upper bound for the parameter value. The dimension of the Maximum
property matches the dimension of the Value property.
For matrix-valued parameters, use indexing to specify upper bounds on
individual elements:
p = realp('K',eye(2));
p.Maximum([1 4]) = 5;
Use scalar expansion to set the same upper bound for all matrix
elements:
p.Maximum = 5;
1-582
realp
Free
Examples
a = realp('a',10);
F = tf(a,[1 a]);
F is a genss object which has the tunable parameter a in its Blocks
property. You can connect F with other tunable or numeric models to
1-583
realp
p = realp('P',eye(2));
p is a 2-by-2 parametric matrix. Because the initial value is the
property to false.
p.Free(1,2) = false;
p.Free(2,1) = false;
See Also
genss | genmat | tf | ss
How To
1-584
reg
Purpose
Syntax
rsys = reg(sys,K,L)
rsys = reg(sys,K,L,sensors,known,controls)
Description
x = Ax + Bu
y = Cx + Du
this yields the regulator
x = [ A LC ( B LD) K ] x + Ly
u = Kx
This regulator should be connected to the plant using positive feedback.
1-585
reg
1-586
reg
Examples
with seven outputs and four inputs, suppose you have designed:
A state-feedback controller gain K using inputs 1, 2, and 4 of the
plant as control inputs
A state estimator with gain L using outputs 4, 7, and 1 of the plant as
sensors, and input 3 of the plant as an additional known input
You can then connect the controller and estimator and form the
complete regulation system by
controls = [1,2,4];
sensors = [4,7,1];
known = [3];
regulator = reg(sys,K,L,sensors,known,controls)
See Also
1-587
replaceBlock
Purpose
Syntax
Mnew = replaceBlock(M,Block1,Value1,...,BlockN,ValueN)
Mnew = replaceBlock(M,blockvalues)
Mnew = replaceBlock(...,mode)
Description
Mnew = replaceBlock(M,Block1,Value1,...,BlockN,ValueN)
Tips
Input
Arguments
1-588
replaceBlock
1-589
replaceBlock
Output
Arguments
Mnew
Matrix or linear model or matrix where the specified blocks are replaced
by the specified replacement values.
Mnew is a numeric array or numeric LTI model when all the specified
replacement values are numeric values or numeric LTI models.
Examples
+
-
C(s)
G(s)
s 1
, and C is a tunable PID controller.
s 1 3
G = zpk(1,[-1,-1,-1],1);
C = ltiblock.pid('C','pid');
Try = feedback(G*C,1)
1-590
replaceBlock
T1 = replaceBlock(Try,'C',5);
T1 is a ss model that equals feedback(G*5,1).
3 Replace C by a PI controller with proportional gain of 5 and integral
gain of 0.1.
C2 = pid(5,0.1);
T2 = replaceBlock(Try,'C',C2);
T2 is a ss model that equals feedback(G*C2,1).
4 Replace C by its current (nominal) value.
T3 = replaceBlock(Try,'C',[]);
T3 is a ss model where C has been replaced by getValue(C).
F s
n2
s2 2n s n2
1-591
replaceBlock
wnvals = [3;5];
zetavals = [0.6 0.8 1.0];
Fsample = replaceBlock(F,'wn',wnvals,'zeta',zetavals);
Fsample is 2-by-3 array of state-space models. Each entry in the
array is the transfer function for the corresponding (wn,zeta) pair.
3 Plot the step response of Fsample.
step(Fsample)
1-592
replaceBlock
The step response plots show the variation in the natural frequency
and damping constant across the six models in the array Fsample.
4 You can set the SamplingGrid property of the model array to help
1-593
replaceBlock
See Also
How To
Generalized Matrices
Generalized and Uncertain LTI Models
Models with Tunable Coefficients
1-594
repsys
Purpose
Syntax
Description
both I/O and array dimensions to produce a model array. The indices S
specify the array dimensions. The size of the array is [size(sys,1)*M,
size(sys,2)*N, size(sys,3)*S1, ...].
Tips
Input
Arguments
sys
Model to replicate.
M
Output
Arguments
rsys
1-595
repsys
Examples
See Also
1-596
append
reshape
Purpose
Syntax
sys = reshape(sys,s1,s2,...,sk)
sys = reshape(sys,[s1 s2 ... sk])
Description
Examples
See Also
ndims | size
1-597
rlocus
Purpose
Syntax
rlocus(sys)
rlocus(sys1,sys2,...)
[r,k] = rlocus(sys)
r = rlocus(sys,k)
Description
rlocus computes the root locus of a SISO open-loop model. The root
locus gives the closed-loop pole trajectories as a function of the feedback
gain k (assuming negative feedback). Root loci are used to study the
effects of varying feedback gains on closed-loop pole locations. In turn,
these locations provide indirect information on the time and frequency
responses.
rlocus(sys) calculates and plots the root locus of the open-loop SISO
model sys. This function can be applied to any of the following negative
feedback loops by setting sys appropriately.
1-598
rlocus
h ( s) =
n ( s)
d ( s)
d(s) + kn(s) = 0
rlocus adaptively selects a set of positive gains k to produce a smooth
plot. Alternatively,
rlocus(sys,k)
Tips
You 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.
Examples
h(s) =
2s2 + 5s + 1
s2 + 2s + 3
1-599
rlocus
rlocus(h)
You can use the right-click menu for rlocus to add grid lines, zoom in or
out, and invoke the Property Editor to customize the plot. Also, click
anywhere on the curve to activate a data marker that displays the gain
value, pole, damping, overshoot, and frequency at the selected point.
See Also
1-600
pole | pzmap
rlocusplot
Purpose
Syntax
h = rlocusplot(sys)
rlocusplot(sys,k)
rlocusplot(sys1,sys2,...)
rlocusplot(AX,...)
rlocusplot(..., plotoptions)
Description
1-601
rlocusplot
Tips
You 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.
Examples
See Also
1-602
rss
Purpose
Syntax
rss(n)
rss(n,p)
rss(n,p,m,s1,...,sn)
Description
rss(n) generates an n-th order model with one input and one output
and returns the model in the state-space object sys. The poles of sys
are random and stable with the possible exception of poles at s = 0
(integrators).
rss(n,p) generates an nth order model with one input and p outputs,
and rss(n,p,m) generates an n-th order model with m inputs and p
outputs. The output sys is always a state-space model.
rss(n,p,m,s1,...,sn) generates an s1-by-...-by-sn array of n-th order
state-space models with m inputs and p outputs.
Use tf, frd, or zpk to convert the state-space object sys to transfer
function, frequency response, or zero-pole-gain form.
Examples
Obtain a random continuous LTI model with three states, two inputs,
and two outputs by typing
sys = rss(3,2,2)
a =
x1
x2
x3
x1
-0.54175
0.09729
0.08304
x2
0.09729
-0.89491
0.58707
x1
x2
x3
u1
-0.88844
0
-0.07162
u2
-2.41459
-0.69435
-1.39139
x3
0.08304
0.58707
-1.95271
b =
c =
1-603
rss
y1
y2
x1
0.32965
0.59854
x2
0.14718
-0.10144
y1
y2
u1
-0.87631
0
u2
-0.32758
0
d =
Continuous-time system.
See Also
1-604
x3
0
0.02805
series
Purpose
Syntax
series
sys = series(sys1,sys2)
sys = series(sys1,sys2,outputs1,inputs2)
Description
series connects two model objects in series. This function accepts any
type of model. The two systems must be either both continuous or both
discrete with identical sample time. Static gains are neutral and can
be specified as regular matrices.
sys = series(sys1,sys2) forms the basic series connection shown
below.
1-605
series
Examples
Consider a state-space system sys1 with five inputs and four outputs
and another system sys2 with two inputs and three outputs. Connect
the two systems in series by connecting outputs 2 and 4 of sys1 with
inputs 1 and 2 of sys2.
outputs1 = [2 4];
inputs2 = [1 2];
sys = series(sys1,sys2,outputs1,inputs2)
See Also
1-606
set
Purpose
Syntax
set(sys,'Property',Value)
set(sys,'Property1',Value1,'Property2',Value2,...)
sysnew = set( ___ )
set(sys,'Property')
Description
not. For a complete list of available system properties for any linear
model type, see the reference page for that model type. This syntax is
equivalent to sys.Property = Value.
set(sys,'Property1',Value1,'Property2',Value2,...) sets
multiple property values with a single statement. Each property
name/property value pair updates one particular property.
sysnew = set( ___ ) returns the modified dynamic system model, and
Examples
You can add an input delay of 0.1 second, label the input as torque,
reset the D matrix to zero, and store its DC gain in the 'Userdata'
property by
1-607
set
set(sys,'inputd',0.1,'inputn','torque','d',0,'user',dcgain(sys))
Note that set does not require any output argument. Check the result
with get by typing
get(sys)
a:
b:
c:
d:
e:
StateName:
InternalDelay:
Ts:
InputDelay:
OutputDelay:
InputName:
OutputName:
InputGroup:
OutputGroup:
Name:
Notes:
UserData:
Tips
1
2
3
0
[]
{''}
[0x1 double]
0
0.1
0
{'torque'}
{''}
[1x1 struct]
[1x1 struct]
''
{}
-2
h ( z) =
1-608
z+2
2
z + 3z + 4
set
( )
h z1 =
1 + 2 z1
1 + 3 z1 + 4 z2
= zh ( z )
Note Because the resulting transfer functions are different, make sure
to use the convention consistent with your choice of variable.
See Also
Tutorials
Model Properties
How To
1-609
setDelayModel
Purpose
Syntax
sys = setDelayModel(H,tau)
sys = setDelayModel(A,B1,B2,C1,C2,D11,D12,D21,D22,tau)
Description
sys
u
H
w
z
exp(-tau*s)
sys = setDelayModel(A,B1,B2,C1,C2,D11,D12,D21,D22,tau)
dx t
Ax t B1u t B2 w t
dt
y t C1 x t D11u t D12 w t
z t C2 x t D21u t D22 w t
wt z t .
1-610
setDelayModel
Tips
setDelayModel(A,B1,B2,C1,C2,D11,D12,D21,D22,tau) constructs
a continuous-time model. You can construct the discrete-time model
described by the state-space equations
x k 1 Ax k B1u k B2 w k
y k C1 x k D11u k D12 w k
z k C2 x k D21u k D22 w k
w k z k .
Input
Arguments
Set of state-space matrices that, with the internal delay vector tau,
explicitly describe the state-space model sys.
Output
Arguments
sys
1-611
setDelayModel
See Also
getDelayModel | ss | lft
Concepts
Internal Delays
Models with Time Delays
1-612
setoptions
Purpose
Syntax
setoptions(h, PlotOpts)
setoptions(h, 'Property1', 'value1', ...)
setoptions(h, PlotOpts, 'Property1', 'value1', ...)
Description
For example,
p = bodeoptions
1-613
setoptions
properties and values are available for a particular plot, type help
<function>options. For example, for Bode plots type
help bodeoptions
For a list of the properties and values available for each plot type, see
Properties and Values Reference.
setoptions(h, PlotOpts, 'Property1', 'value1', ...) first
assigns plot properties as defined in @PlotOptions, and then overrides
Examples
1-614
setoptions
To change the frequency units using property/value pairs, use this code.
sys=tf(1,[1 1]);
h=bodeplot(sys);
setoptions(h,'FreqUnits','Hz');
See Also
getoptions
1-615
setBlockValue
Purpose
Syntax
M = setBlockValue(M0,blockname,val)
M = setBlockValue(M0,blockvalues)
M = setBlockValue(M0,Mref)
Description
Input
Arguments
M0
1-616
setBlockValue
Generalized Model that shares some Control Design Blocks with M0.
The values of these blocks in Mref are used to update their counterparts
in M0.
Output
Arguments
Examples
1-617
setBlockValue
G = tf([1,0.0007],[1,0.00034,0.00086]);
Cpi = ltiblock.pid('Cpi','pi');
a = realp('a',10);
F0 = tf(a,[1 a]);
C0 = Cpi*F0;
T0 = feedback(G*C0,1);
T = hinfstruct(T0);
Obtain a Numeric LTI model of the controller with the tuned values
using getValue.
CVal = getValue(C0,T);
1-618
setBlockValue
See Also
1-619
setValue
Purpose
Syntax
blk = setValue(blk0,val)
Description
Input
Arguments
blk0
Output
Arguments
blk
See Also
1-620
Control Design Block of the same type as blk0, whose parameters are
updated to best match the parameters of val.
sgrid
Purpose
Syntax
sgrid
sgrid(z,wn)
Description
sgrid generates, for pole-zero and root locus plots, a grid of constant
damping factors from zero to one in steps of 0.1 and natural frequencies
from zero to 10 rad/sec in steps of one rad/sec, and plots the grid over
the current axis. If the current axis contains a continuous s-plane root
locus diagram or pole-zero map, sgrid draws the grid over the plot.
sgrid(z,wn) plots a grid of constant damping factor and natural
frequency lines for the damping factors and natural frequencies in the
vectors z and wn, respectively. If the current axis contains a continuous
s-plane root locus diagram or pole-zero map, sgrid(z,wn) draws the
grid over the plot.
Alternatively, you can select Grid from the right-click menu to generate
the same s-plane grid.
Examples
Plot s-plane grid lines on the root locus for the following system.
H (s) =
2s2 + 5s + 1
s2 + 2s + 3
1-621
sgrid
See Also
1-622
showBlockValue
Purpose
Syntax
showBlockValue(M)
Description
Input
Arguments
Examples
Create a tunable genss model, and display the current value of its
tunable elements.
Generalized Model.
G
C
a
F
T
=
=
=
=
=
zpk([],[-1,-1],1);
ltiblock.pid('C','PID');
realp('a',10);
tf(a,[1 a]);
feedback(G*C,1)*F;
showBlockValue(T)
C =
Continuous-time I-only controller:
1
Ki * --s
With Ki = 0.001
----------------------------------a = 10
1-623
showBlockValue
Tips
See Also
1-624
showTunable
Purpose
Syntax
showTunable(M)
Description
Input
Arguments
M - Input model
Examples
+
-
F
The control structure includes a PI controller C and a tunable low-pass
filter in the feedback path. The plant G is a third-order system.
Create models of the system components and connect them together to
create a tunable closed-loop model of the control system.
s = tf('s');
1-625
showTunable
Create a tuning requirement that forces the output y to track the input
r, and tune the system to meet that requirement.
Req = TuningGoal.Tracking('r','y',0.05);
[T,fSoft,~] = systune(T0,Req);
systune finds values for the tunable parameters that optimally meet
the tracking requirement. The output T is a genss model with the
same Control Design Blocks as T0. The current values of those blocks
1-626
showTunable
Name: C
Continuous-time PI controller in parallel form.
----------------------------------a = 68.6
showTunable displays the values of the tunable blocks only. If you use
showBlockValue instead, the display also includes the switch block X.
Tips
See Also
Concepts
Generalized Models
Control Design Blocks
1-627
sigma
Purpose
Syntax
sigma(sys)
sigma(sys,w)
sigma(sys,[],type)
sigma(sys,w,type)
sigma(sys1,sys2,...,sysN,w,type)
sigma(sys1,'PlotStyle1',...,sysN,'PlotStyleN',w,type)
sv = sigma(sys,w)
[sv,w] = sigma(sys)
Description
H ( e jTs )
for frequencies between 0 and the Nyquist frequency N = /Ts.
The singular values of the frequency response extend the Bode
magnitude response for MIMO systems and are useful in robustness
analysis. The singular value response of a SISO system is identical to
its Bode magnitude response. When invoked without output arguments,
sigma produces a singular value plot on the screen.
sigma(sys) plots the singular values of the frequency response of a
model sys. This model can be continuous or discrete, and SISO or
1-628
sigma
type = 2
type = 3
These options are available only for square systems, that is, with the
same number of inputs and outputs.
sigma(sys1,sys2,...,sysN,w,type) plots the singular value plots of
several LTI models on a single figure. The arguments w and type are
optional. The models sys1,sys2,...,sysN need not have the same
number of inputs and outputs. Each model can be either continuousor discrete-time.
sigma(sys1,'PlotStyle1',...,sysN,'PlotStyleN',w,type)
Tips
You 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.
Examples
1-629
sigma
0
H (s) =
s+1
s + 5
s + s + 10
2
s + 6
3s
and I + H(s).
You can do this by typing
H = [0 tf([3 0],[1 1 10]) ; tf([1 1],[1 5]) tf(2,[1 6])]
subplot(211)
sigma(H)
subplot(212)
sigma(H,[],2)
1-630
sigma
Algorithms
sigma uses the MATLAB function svd to compute the singular values
of a complex matrix.
For TF, ZPK, and SS models, sigma computes the frequency response
using the freqresp algorithms. As a result, small discrepancies may
exist between the sigma responses for equivalent TF, ZPK, and SS
representations of a given model.
See Also
1-631
sigmaoptions
Purpose
Syntax
P = sigmaoptions
P = sigmaoptions('cstprefs')
Description
1-632
Option
Description
TickLabel
Grid
XlimMode, YlimMode
Limit modes
Xlim, Ylim
Axes limits
IOGrouping
InputLabels, OutputLabels
InputVisible, OutputVisible
sigmaoptions
Option
Description
FreqUnits
1-633
sigmaoptions
Option
Description
'cycles/year'
Default: 'rad/s'
You can also specify 'auto'
which uses frequency units
rad/TimeUnit relative to system
time units specified in the
TimeUnit property. For multiple
systems with different time units,
the units of the first system are
used.
Examples
FreqScale
Frequency scale
Specified as one of the following
strings: 'linear' | 'log'
Default: 'log'
MagUnits
Magnitude units
Specified as one of the following
strings: 'dB' | 'abs'
Default: 'dB'
MagScale
Magnitude scale
Specified as one of the following
strings: 'linear' | 'log'
Default: 'linear'
The following singular value plot is created with the frequency units in
Hz.
1-634
sigmaoptions
See Also
1-635
sigmaplot
Purpose
Syntax
h = sigmaplot(sys)
sigmaplot(sys,{wmin,wmax})
sigmaplot(sys,w)
sigmaplot(sys,w,TYPE)
sigmaplot(AX,...)
sigmaplot(..., plotoptions)
Description
1-636
TYPE = 1
-->
SV of inv(SYS)
TYPE = 2
-->
SV of I + SYS
TYPE = 3
-->
SV of I + inv(SYS)
sigmaplot
Tips
You 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.
Examples
See Also
1-637
sisoinit
Purpose
Syntax
init_config = sisoinit(config)
Description
for initializing Graphical Tuning window of the SISO Design Tool with
the one of the following control system configurations:
1-638
sisoinit
Properties
Values
Name
String
Description
String
Value
LTI object
Name
String
Value
LTI object
Name
String
Value
LTI object
Row or column array of LTI objects.
If the plant G is also an array of LTI
objects, the lengths of H and G must
match.
1-639
sisoinit
Properties
Values
Name
String
Description
String
Value
LTI object
Loop Properties
Loops
Properties
Values
OL1
Name
Description
View
String
String
Name
Description
View
String
String
CL1
Examples
'rlocus' 'bode'
'bode'
Initialize SISO Design Tool with C in feedback path using an LTI model:
% Single-loop configuration with C in the feedback path.
T = sisoinit(2);
% Model for plant G.
T.G.Value = tf(1, [1 1]);
% Initial compensator value.
T.C.Value = tf(1,[1 2]);
% Views for tuning Open-Loop OL1.
T.OL1.View = {'rlocus','nichols'};
% Launch SISO Design Tool using configuration T
sisotool(T)
1-640
sisoinit
See Also
sisotool
How To
1-641
sisotool
Purpose
Syntax
sisotool
sisotool(plant)
sisotool(plant,comp)
sisotool(plant,comp,sensor,prefilt)
sisotool(views)
sisotool(views,plant,comp)
sisotool(initdata)
sisotool(sessiondata)
Description
1-642
sisotool
There are six control architectures available. See sisoinit for more
information.
This picture shows the SISO Design Graphical editor.
1-643
sisotool
models.
sisotool(plant,comp) initializes the plant model G to plant, the
opens a SISO Design Tool with only the Bode Diagrams. If there is
more than one view, the views are specified in a cell array.
sisotool(initdata) initializes the SISO Design Tool with more
general control system configurations. Use sisoinit to create the
initialization data structure initdata.
sisotool(sessiondata) opens the SISO Design Tool with a previously
saved session where sessiondata is the MAT-file for the saved session.
1-644
sisotool
Examples
See Also
Tutorials
1-645
sisotool
How To
1-646
size
Purpose
Syntax
size(sys)
d = size(sys)
Ny = size(sys,1)
Nu = size(sys,2)
Sk = size(sys,2+k)
Nf = size(sys,'frequency')
Description
The row vector d = [Ny Nu] for a single dynamic model sys with
Ny outputs and Nu inputs
The row vector d = [Ny Nu S1 S2 ... Sp] for an
S1-by-S2-by-...-by-Sp array of dynamic models with Ny outputs and Nu
inputs
Ny = size(sys,1) returns the number of outputs of sys.
Nu = size(sys,2) returns the number of inputs of sys.
Sk = size(sys,2+k) returns the length of the k-th array dimension
when sys is a model array.
Nf = size(sys,'frequency') returns the number of frequencies
when sys is a frequency response data model. This is the same as the
length of sys.frequency.
Examples
Example 1
Consider the model array of random state-space models
1-647
size
sys = rss(5,3,2,3);
Example 2
Consider the process model:
sys = idproc({'p1d', 'p2'; 'p3uz', 'p0'});
See Also
1-648
sminreal
Purpose
Syntax
msys = sminreal(sys)
Description
Tips
Examples
1-649
sminreal
See Also
1-650
minreal
ss
Purpose
Syntax
sys = ss(a,b,c,d)
sys = ss(a,b,c,d,Ts)
sys = ss(d)
sys = ss(a,b,c,d,ltisys)
sys_ss = ss(sys)
sys_ss = ss(sys,'minimal')
sys_ss = ss(sys,'explicit')
sys_ss = ss(sys, 'measured')
sys_ss = ss(sys, 'noise')
sys_ss = ss(sys, 'augmented')
Description
x = Ax + Bu
y = Cx + Du
For a model with Nx states, Ny outputs, and Nu inputs:
a is an Nx-by-Nx real- or complex-valued matrix.
b is an Nx-by-Nu real- or complex-valued matrix.
c is an Ny-by-Nx real- or complex-valued matrix.
d is an Ny-by-Nu real- or complex-valued matrix.
To set D = 0 , set d to the scalar 0 (zero), regardless of the dimension.
sys = ss(a,b,c,d,Ts) creates the discrete-time model
1-651
ss
x[ n + 1] = Ax[ n] + Bu[ n]
y[ n] = Cx[ n] + Du[ n]
with sample time Ts (in seconds). Set Ts = -1 or Ts = [] to leave the
sample time unspecified.
sys = ss(d) specifies a static gain matrix D and is equivalent to
sys = ss([],[],[],d)
sys = ss(a,b,c,d,ltisys) creates a state-space model with
properties inherited from the model ltisys (including the sample time).
1-652
ss
Note Conversions to state space are not uniquely defined in the SISO
case. They are also not guaranteed to produce a minimal realization
in the MIMO case. For more information, see Recommended Working
Representation.
inputs such that the first nu inputs represent the channels u(t)
1-653
ss
Properties
State-space matrices.
a State matrix A. Square real- or complex-valued matrix with
as many rows as states.
b Input-to-state matrix B. Real- or complex-valued matrix with as
many rows as states and as many columns as inputs.
c State-to-output matrix C. Real- or complex-valued matrix with
as many rows as outputs and as many columns as states.
d Feedthrough matrix D. Real- or complex-valued matrix with as
many rows as outputs and as many columns as inputs.
1-654
ss
State units. Use StateUnit to keep track of the units each state is
expressed in. For first-order models, set StateUnit to a string. For
models with two or more states, set StateUnit to a cell array of strings.
StateUnit has no effect on system behavior.
Default: Empty string '' for all states
InternalDelay
1-655
ss
Input delay for each input channel, specified as a numeric vector. For
continuous-time systems, specify input delays in the time unit stored
in the TimeUnit property. For discrete-time systems, specify input
delays in integer multiples of the sampling period Ts. For example,
InputDelay = 3 means a delay of three sampling periods.
For a system with Nu inputs, set InputDelay to an Nu-by-1 vector. Each
entry of this vector is a numerical value that represents the input delay
for the corresponding input channel.
You can also set InputDelay to a scalar value to apply the same delay
to all channels.
OutputDelay
1-656
ss
1-657
ss
'weeks'
'months'
'years'
Changing this property changes the overall system behavior. Use
chgTimeUnit to convert between time units without modifying system
behavior.
Default: 'seconds'
InputName
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
1-658
ss
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-659
ss
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
1-660
ss
Name
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
SamplingGrid
1-661
ss
sysarr.SamplingGrid = struct('time',0:10)
When you display M, each entry in the array includes the corresponding
zeta and w values.
M
M(:,:,1,1) [zeta=0.3, w=5] =
25
-------------s^2 + 3 s + 25
Default: []
Algorithms
1-662
ss
-10
0
sys.a
ans =
-1
2
-5
0
Examples
Example 1
Discrete-Time State-Space Model
Create a state-space model with a sampling time of 0.25 s and the
following state-space matrices:
0 1
A=
5 2
0
B=
3
C = [ 0 1]
D = [0]
1-663
ss
A =
B =
C =
D =
sys
[0 1;-5 -2];
[0;3];
[0 1];
0;
= ss(A,B,C,D,0.25);
Example 2
Discrete-Time State-Space Model with Custom State and Input
Names
Create a discrete-time model with matrices A,B,C,D and sample time
0.05 second.
sys = ss(A,B,C,D,0.05,'statename',{'position' 'velocity'},...
'inputname','force',...
'notes','Created 01/16/11');
This model has two states labeled position and velocity, and one
input labeled force (the dimensions of A,B,C,D should be consistent
with these numbers of states and inputs). Finally, a note is attached
with the date of creation of the model.
Example 3
Convert Transfer Function Model to State-Space Model
Convert a transfer function model to a state-space model.
s+1
2
s + 3s + 3s + 2
H ( s) =
s2 + 3
2
s + s+1
by typing
H = [tf([1 1],[1 3 3 2]) ; tf([1 0 3],[1 1 1])];
sys = ss(H);
1-664
ss
size(sys)
State-space model with 2 outputs, 1 input, and 5 states.
s+1
1
2
0 s + s + 1
H (s) = s + 2
1 s + 3
0
2
s + s + 1
Example 4
Descriptor State-Space Model
Create a descriptor state-space model.
a = [2 -4; 4 2];
b = [-1; 0.5];
c = [-0.5, -2];
d = [-1];
e = [1 0; -3 0.5];
% Create a descriptor state-space model.
sys1 = dss(a,b,c,d,e);
% Compute an explicit realization.
sys2 = ss(sys1,'explicit')
1-665
ss
x1
2
20
x2
-4
-20
b =
x1
x2
u1
-1
-5
y1
x1
-0.5
y1
u1
-1
c =
x2
-2
d =
Continuous-time model.
1-666
ss
Example 5
Generalized State-Space Model
This example shows how to create a state-space (genss) model having
both fixed and tunable parameters.
Create a state-space model having the following state-space matrices:
1 a b
A
,
0 ab
3.0
B
,
1 .5
C 0 .3 0 ,
D 0,
where a and b are tunable parameters, whose initial values are 1 and
3, respectively.
1 Create the tunable parameters using realp.
a = realp('a',-1);
1-667
ss
b = realp('b',3);
2 Define a generalized matrix using algebraic expressions of a and b.
A = [1 a+b;0 a*b]
A is a generalized matrix whose Blocks property contains a and b.
The initial value of A is M = [1 2;0 -3], from the initial values of
a and b.
3 Create the fixed-value state-space matrices.
B = [-3.0;1.5];
C = [0.3 0];
D = 0;
4 Use ss to create the state-space model.
sys = ss(A,B,C,D)
sys is a generalized LTI model (genss) with tunable parameters a and b.
Example 6
Extract the measured and noise components of an identified polynomial
model into two separate state-space models. The former (measured
component) can serve as a plant model while the latter can serve as a
disturbance model for control system design.
load icEngine
z = iddata(y,u,0.04);
sys = ssest(z, 3);
sysMeas = ss(sys, 'measured')
sysNoise = ss(sys, 'noise')
1-668
ss
See Also
Tutorials
State-Space Model
MIMO State-Space Model
How To
1-669
ss2ss
Purpose
Syntax
sysT = ss2ss(sys,T)
Description
x Ax Bu
y Cx Du
or the innovations form used by the identified state-space (IDSS)
models:
dx
Ax Bu Ke
dt
y Cx Du e
(or their discrete-time counterpart), ss2ss performs the similarity
transformation x = Tx on the state vector x and produces the equivalent
state-space model sysT with equations.
x = TAT 1 x + TBu
y = CT 1 x + Du
or, in the case of an IDSS model:
1-670
ss2ss
Examples
See Also
balreal | canon
1-671
ssdata
Purpose
Syntax
[a,b,c,d] = ssdata(sys)
[a,b,c,d,Ts] = ssdata(sys)
Description
You can access the remaining LTI properties of sys with get or by
direct referencing. For example:
sys.statename
See Also
1-672
stabsep
Purpose
Stable-unstable decomposition
Syntax
[GS,GNS]=stabsep(G)
[G1,GNS] = stabsep(G,'abstol',ATOL,'reltol',RTOL)
[G1,G2]=stabsep(G, ...,'Mode', MODE,'Offset', ALPHA)
[G1,G2] = stabsep(G, opts)
Description
unstable parts
G = GS + GNS
where GS contains all stable modes that can be separated from the
unstable modes in a numerically stable way, and GNS contains the
remaining modes. GNS is always strictly proper.
[G1,GNS] = stabsep(G,'abstol',ATOL,'reltol',RTOL) specifies
absolute and relative error tolerances for the stable/unstable
decomposition. The frequency responses of G and GS + GNS should differ
by no more than ATOL+RTOL*abs(G). Increasing these tolerances helps
separate nearby stable and unstable modes at the expense of accuracy.
The default values are ATOL=0 and RTOL=1e-8.
[G1,G2]=stabsep(G, ...,'Mode', MODE,'Offset', ALPHA) produces
a more general stable/unstable decomposition where G1 includes all
separable poles lying in the regions defined using offset ALPHA. This can
be useful when there are numerical accuracy issues. For example, if you
have a pair of poles close to, but slightly to the left of the j-axis, you
can decide not to include them in the stable part of the decomposition
if numerical considerations lead you to believe that the poles may be
in fact unstable
1-673
stabsep
Re(s)<-ALPHA*max(1,|Im(s)|)
Re(s)> ALPHA*max(1,|Im(s)|)
Examples
The unstable part of the decomposition has poles at +1 and -.001 (which
is nominally stable).
hns
Zero/pole/gain:
0.050075 (s-1)
--------------(s+0.001) (s-1)
See Also
1-674
stabsepOptions | modsep
stabsepOptions
Purpose
Syntax
opts = stabsepOptions
opts = stabsepOptions('OptionName', OptionValue)
Description
command.
opts = stabsepOptions('OptionName', OptionValue) accepts one
or more comma-separated name/value pairs. Specify OptionName inside
single quotes.
Input
Arguments
'unstable'
Default: 'stable'
AbsTol, RelTol
1-675
stabsepOptions
Offset for the stable/unstable boundary. Positive scalar value. The first
output of stabsepincludes only poles satisfying:
Continuous time:
Re(s) < -Offset * max(1,|Im(s)|) (Focus = 'stable')
Re(s) > Offset * max(1,|Im(s)|) (Focus = 'unstable')
Discrete time:
|z| < 1 - Offset (Focus = 'stable')
|z| >1 + Offset (Focus = 'unstable')
Increase the value of Offset to treat poles close to the stability
boundary as unstable.
Default: 0
For additional information on the options and how to use them, see
the stabsep reference page.
Examples
G ( s) =
10 ( s + 0.5 )
( s + 10 ) ( s + 2 5i) ( s + 2 + 5i)
6
Use the Offset option to force stabsep to exclude the pole at s = 106
from the stable term of the stable/unstable decomposition.
G = zpk(-.5,[-1e-6 -2+5i -2-5i],10);
opts = stabsepOptions('Offset',.001); % Create option set
[G1,G2] = stabsep(G,opts)
% treats -1e-6 as unstable
1-676
stabsepOptions
(s^2 + 4s + 29)
Zero/pole/gain:
0.17241
---------(s+1e-006)
See Also
stabsep
1-677
stack
Purpose
Syntax
sys = stack(arraydim,sys1,sys2,...)
Description
models must have the same number of inputs and outputs (the same
I/O dimensions), but the number of states can vary. The I/O dimensions
are not counted in the array dimensions. For more information about
model arrays and array dimensions, see Model Arrays.
For arrays of state-space models with variable order, you cannot use the
dot operator (e.g., sys.a) to access arrays. Use the syntax
[a,b,c,d] = ssdata(sys,'cell')
Examples
Example 1
If sys1 and sys2 are two models:
stack(1,sys1,sys2) produces a 2-by-1 model array.
stack(2,sys1,sys2) produces a 1-by-2 model array.
stack(3,sys1,sys2) produces a 1-by-1-by-2 model array.
Example 2
Stack identified state-space models derived from the same estimation
data and compare their bode responses.
load iddata1 z1
sysc = cell(1,5);
opt = ssestOptions('Focus','simulation');
for i = 1:5
1-678
stack
sysc{i} = ssest(z1,i-1,opt);
end
sysArray = stack(1, sysc{:});
bode(sysArray);
1-679
step
Purpose
Syntax
step(sys)
step(sys,Tfinal)
step(sys,t)
step(sys1,sys2,...,sysN)
step(sys1,sys2,...,sysN,Tfinal)
step(sys1,sys2,...,sysN,t)
y = step(sys,t)
[y,t] = step(sys)
[y,t] = step(sys,Tfinal)
[y,t,x] = step(sys)
[y,t,x,ysd] = step(sys)
[y,...] = step(sys,...,options)
Description
step calculates the step response of a dynamic system. For the state
space case, zero initial state is assumed. When it is invoked with no
output arguments, this function plots the step response on the screen.
step(sys) plots the step response of an arbitrary dynamic system
model sys. This model can be continuous or discrete, and SISO or
1-680
step
page 1-687). The step command always applies the step input at t=0,
regardless of Ti.
To plot the step response of several modelssys1,..., sysN on a single
figure, use
step(sys1,sys2,...,sysN)
step(sys1,sys2,...,sysN,Tfinal)
step(sys1,sys2,...,sysN,t)
All of the systems plotted on a single plot must have the same number
of inputs and outputs. You can, however, plot a mix of continuous- and
discrete-time systems on a single plot. This syntax is useful to compare
the step responses of multiple systems.
You can also specify a distinctive color, linestyle, marker, or all three
for each system. For example,
step(sys1,'y:',sys2,'g--')
plots the step response of sys1 with a dotted yellow line and the step
response of sys2 with a green dashed line.
When invoked with output arguments:
y = step(sys,t)
[y,t] = step(sys)
[y,t] = step(sys,Tfinal)
[y,t,x] = step(sys)
step returns the output response y, the time vector t used for
simulation (if not supplied as an input argument), and the state
trajectories x (for state-space models only). No plot generates on the
screen. For single-input systems, y has as many rows as time samples
(length of t), and as many columns as outputs. In the multi-input case,
the step responses of each input channel are stacked up along the third
dimension of y. The dimensions of y are then
1-681
step
[y,...]
Tips
You 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.
Examples
Example 1
Step Response Plot of Dynamic System
Plot the step response of the following second-order state-space model.
x1 0.5572 0.7814 x1 1 1 u1
x = 0.7814
x + 0 2 u
0
2
2
2
x1
y = [1.9691 6.4493]
x2
a = [-0.5572
-0.7814;0.7814
b = [1 -1;0 2];
c = [1.9691 6.4493];
sys = ss(a,b,c,0);
step(sys)
1-682
0];
step
The left plot shows the step response of the first input channel, and the
right plot shows the step response of the second input channel.
1-683
step
Example 3
Compare the step response of a parametric identified model to a
non-parametric (empirical) model/ Also view their 3- confidence
regions.
1-684
step
load iddata1 z1
sys1 = ssest(z1,4);
parametric model
sys2 = impulseest(z1);
non-parametric model
[y1, ~, ~, ysd1] = step(sys1,t);
[y2, ~, ~, ysd2] = step(sys2,t);
plot(t, y1, 'b', t, y1+3*ysd1, 'b:', t, y1-3*ysd1, 'b:')
hold on
plot(t, y2, 'g', t, y2+3*ysd2, 'g:', t, y2-3*ysd2, 'g:')
Example 4
Validation the linearization of a nonlinear ARX model by comparing
their small amplitude step responses.
nlsys = nlarx(z2,[4 3 10],'tree','custom',...
{'sin(y1(t-2)*u1(t))+y1(t-2)*u1(t)+u1(t).*u1(t-13)',...
'y1(t-5)*y1(t-5)*y1(t-1)'},'nlr',[1:5, 7 9]);
1-685
step
To compare, add the steady-state offset, y0, to the response of the linear
system:
plot(t, ynl, t, yl+y0)
legend('Nonlinear', 'Linear with offset')
Example 5
Compute the step response of an identified time series model.
A time series model, also called a signal model, is one without measured
input signals. The step plot of this model uses its (unmeasured) noise
channel as the input channel to which the step signal is applied.
load iddata9
sys = ar(z9, 4);
ys is a model of the form A y(t) = e(t), where e(t) represents the
noise channel. For computation of step response, e(t) is treated as an
input channel, and is named "e@y1".
1-686
step
step(sys)
Algorithms
References
See Also
1-687
stepDataOptions
Purpose
Syntax
opt = stepDataOptions
opt = stepDataOptions(Name,Value)
Description
Input
Arguments
Input signal level for all time t < 0, as shown in the next figure.
Default: 0
1-688
stepDataOptions
StepAmplitude
Output
Arguments
opt
Examples
Specify the input offset and amplitude level for step response.
sys = tf(1,[1,1]);
opt = stepDataOptions('InputOffset',-1,'StepAmplitude',2);
[y,t] = step(sys,opt)
See Also
step
1-689
stepinfo
Purpose
Syntax
S
S
S
S
S
S
Description
=
=
=
=
=
=
stepinfo(y,t,yfinal)
stepinfo(y,t)
stepinfo(y)
stepinfo(sys)
stepinfo(...,'SettlingTimeThreshold',ST)
stepinfo(...,'RiseTimeLimits',RT)
1-690
stepinfo
has settled when the error |y(t) - yfinal| becomes smaller than a
fraction ST of its peak value. The default value is ST=0.02 (2%).
S = stepinfo(...,'RiseTimeLimits',RT) lets you specify the lower
and upper thresholds used in the rise time calculation. By default,
the rise time is the time the response takes to rise from 10 to 90% of
the steady-state value (RT=[0.1 0.9]). Note that RT(2) is also used
to calculate SettlingMin and SettlingMax.
Examples
See Also
7.4454
13.9378
2.3737
2.5201
0.8032
0
2.5201
15.1869
step | lsiminfo
1-691
stepplot
Purpose
Syntax
h = stepplot(sys)
stepplot(sys,Tfinal)
stepplot(sys,t)
stepplot(sys1,sys2,...,sysN)
stepplot(sys1,sys2,...,sysN,Tfinal)
stepplot(sys1,sys2,...,sysN,t)
stepplot(AX,...)
stepplot(..., plotoptions)
stepplot(..., dataoptions)
Description
Type
help timeoptions
1-692
stepplot
You can also specify a color, line style, and marker for each system, as in
stepplot(sys1,'r',sys2,'y--',sys3,'gx')
stepplot(AX,...) plots into the axes with handle AX.
stepplot(..., plotoptions) customizes the plot appearance using
the options set, plotoptions. Use timeOptions to create the options
set.
stepplot(..., dataoptions) specifies options such as the step
amplitude and input offset using the options set, dataoptions. Use
stepDataOptions to create the options set.
Tips
You 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.
Examples
Example 1
Use the plot handle to normalize the responses on a step plot.
sys = rss(3);
h = stepplot(sys);
% Normalize responses.
setoptions(h,'Normalize','on');
Example 2
Compare the step response of a parametric identified model to a
non-parametric (empirical) model, and view their 3- confidence
1-693
stepplot
non-parametric model
sys2 = impulseest(z1);
t = -1:0.1:5;
h = stepplot(sys1,sys2,t);
showConfidence(h,3)
Example 3
Plot the step response of a nonlinear (Hammerstein-Wiener) model using
a starting offset of 2 and step amplitude of 0.5. (Hammerstein-Weiner
models require System Identification Toolbox software.)
load twotankdata
z = iddata(y, u, 0.2, 'Name', 'Two tank system');
sys = nlhw(z, [1 5 3], pwlinear, poly1d);
dataoptions = stepDataOptions('InputOffset', 2, 'StepAmplitude', 0.5);
stepplot(sys,60,dataoptions);
See Also
1-694
strseq
Purpose
Syntax
strvec = strseq(STR,INDICES)
Description
Examples
See Also
strcat | connect
1-695
sumblk
Purpose
Syntax
S = sumblk(formula)
S = sumblk(formula,signalsize)
S = sumblk(formula,signames1,signames2,...)
Description
junction. The input and output signals are vectors with signalsize
elements.
S = sumblk(formula,signames1,signames2,...) replaces aliases
(signal names beginning with %) in formula by the signal names
Tips
Input
Arguments
formula
String specifying the equation that relates the input and output signals
of the summing junction transfer function S. For example, the following
command:
S = sumblk('e = r - y + d')
creates a summing junction with input names 'r', 'y', and 'd', output
name 'e' and equation e = r-y+d.
If you specify a signalsize greater than 1, the inputs and outputs
of S are vector-valued signals. sumblk automatically performs vector
expansion of the signal names of S. For example, the following command:
S = sumblk('v = u + d',2)
1-696
sumblk
dimension.
signalsize
Signal names to replace one alias (signal name beginning with %) in the
formula string. You must provide one signames argument for each
alias in formula.
Specify signames as:
A cell array of name strings.
1-697
sumblk
Output
Arguments
Examples
u1
u2
u3
ans =
1-698
sumblk
'u1'
'u2'
'u3'
ans =
'u(1)'
'u(2)'
'd(1)'
'd(2)'
1-699
sumblk
e 1 setpoint 1 alpha d 1
e 2 setpoint 2 q d 2
The signals alpha and q have custom names that are not merely the
vector expansion of a single signal name. Therefore, use an alias in the
formula specifying the summing junction.
S = sumblk('e = setpoint - %y + d', {'alpha';'q'});
sumblk replaces the alias %y with the cell array {'alpha';'q'}.
S.OutputName,S.Inputname
ans =
'e(1)'
'e(2)'
ans =
'setpoint(1)'
'setpoint(2)'
'alpha'
'q'
'd(1)'
'd(2)'
See Also
How To
1-700
tf
Purpose
Syntax
sys =
sys =
sys =
sys =
tfsys
tfsys
tfsys
tfsys
Description
tf(num,den)
tf(num,den,Ts)
tf(M)
tf(num,den,ltisys)
= tf(sys)
= tf(sys, 'measured')
= tf(sys, 'noise')
= tf(sys, 'augmented')
1-701
tf
Use the tf command with cell array arguments. In this case, num and
den are cell arrays of row vectors with as many rows as outputs and
as many columns as inputs. The row vectors num{i,j} and den{i,j}
specify the numerator and denominator of the transfer function from
input j to output i.
For examples of creating MIMO transfer functions, see Examples on
page 1-704 and MIMO Transfer Function Model in the Control System
Toolbox User Guide.
If all SISO entries of a MIMO transfer function have the same
denominator, you can set den to the row vector representation of this
common denominator. See "Examples" for more details.
sys = tf(num,den,Ts) creates a discrete-time transfer function
with sample time Ts (in seconds). Set Ts = -1 to leave the sample
time unspecified. The input arguments num and den are as in the
continuous-time case and must list the numerator and denominator
coefficients in descending powers of z.
sys = tf(M) creates a static gain M (scalar or matrix).
sys = tf(num,den,ltisys) creates a transfer function with
properties inherited from the dynamic system model ltisys (including
Each pair specifies a particular property of the model, for example, the
input names or the transfer function variable. For information about
the properties of tf objects, see Properties on page 1-710. Note that
1-702
tf
sys = tf(num,den,'Property1',Value1,...,'PropertyN',ValueN)
is a shortcut for
sys = tf(num,den)
set(sys,'Property1',Value1,...,'PropertyN',ValueN)
1-703
tf
Examples
Example 1
Transfer Function Model with One-Input Two-Outputs
1-704
tf
p+1
p + 2p + 2
H ( p) =
ang. velocity:
1
p
Example 2
Transfer Function Model Using Rational Expression
To use a rational expression to create a SISO TF model, type
s = tf('s');
H = s/(s^2 + 2*s +10);
1-705
tf
Example 3
Multiple-Input Multiple-Output Transfer Function Model
Specify the discrete MIMO transfer function
1
z + 0 .3
H ( z) =
z + 2
z + 0.3
z
z + 0 .3
3
z + 0.3
with common denominator d (z) = z + 0.3 and sample time of 0.2 seconds.
nums = {1 [1 0];[-1 2] 3};
Ts = 0.2;
H = tf(nums,[1 0.3],Ts)
Example 4
Convert State-Space Model to Transfer Function
Compute the transfer function of the state-space model with the
following data.
2 1
A=
,
1 2
1 1
B=
,
2 1
C = [1 0] ,
D = [ 0 1].
To do this, type
sys = ss([-2 -1;1 -2],[1 1;2 -1],[1 0],[0 1]);
tf(sys)
1-706
tf
Example 5
Array of Transfer Function Models
You can use a for loop to specify a 10-by-1 array of SISO TF models.
H = tf(zeros(1,1,10));
s = tf('s')
for k=1:10,
H(:,:,k) = k/(s^2+s+k);
end
The first statement pre-allocates the TF array and fills it with zero
transfer functions.
Example 6
Tunable Low-Pass Filter
This example shows how to create the low-pass filter F = a/(s + a) with
one tunable parameter a.
You cannot use ltiblock.tf to represent F, because the numerator
and denominator coefficients of an ltiblock.tf block are independent.
Instead, construct F using the tunable real parameter object realp.
1 Create a tunable real parameter.
a = realp('a',10);
1-707
tf
F = tf(a,[1 a]);
F is a genss object which has the tunable parameter a in its Blocks
property. You can connect F with other tunable or numeric models to
Example 7
Extract the measured and noise components of an identified polynomial
model into two separate transfer functions. The former (measured
component) can serve as a plant model while the latter can serve as a
disturbance model for control system design.
load icEngine;
z = iddata(y,u,0.04);
nb = 2; nf = 2; nc = 1; nd = 3; nk = 3;
sys = bj(z, [nb nc nd nf nk]);
sys is a model of the form: y(t) = B/F u(t) + C/D e(t), where B/F
represents the measured component and C/D the noise component.
sysMeas = tf(sys, 'measured')
sysNoise = tf(sys, 'noise')
Discrete-Time
Conventions
The control and digital signal processing (DSP) communities tend to use
different conventions to specify discrete transfer functions. Most control
engineers use the z variable and order the numerator and denominator
terms in descending powers of z, for example,
h ( z) =
1-708
z2
z2 + 2 z + 3
tf
( )
h z1 =
1
1 + 2z
+ 3 z2
Variable
Convention
a1 a0] to specify
'z^-1'
bk] to specify
g ( z) =
z+1
2
z + 2z + 3
1-709
tf
( )
h z1 =
1 + z1
1 + 2 z1 + 3 z2
= zg ( z ) .
See also filt for direct specification of discrete transfer functions using
the DSP convention.
Note that tf stores data so that the numerator and denominator lengths
are made equal. Specifically, tf stores the values
num = [0 1 1]; den = [1 2 3];
for g (the numerator is padded with zeros on the left) and the values
num = [1 1 0]; den = [1 2 3];
Properties
1-710
tf
1-711
tf
You can also set ioDelay to a scalar value to apply the same delay to all
input/output pairs.
Default: 0 for all input/output pairs
InputDelay - Input delays
0 (default) | scalar | vector
Input delay for each input channel, specified as a numeric vector. For
continuous-time systems, specify input delays in the time unit stored
in the TimeUnit property. For discrete-time systems, specify input
delays in integer multiples of the sampling period Ts. For example,
InputDelay = 3 means a delay of three sampling periods.
For a system with Nu inputs, set InputDelay to an Nu-by-1 vector. Each
entry of this vector is a numerical value that represents the input delay
for the corresponding input channel.
You can also set InputDelay to a scalar value to apply the same delay
to all channels.
OutputDelay
1-712
tf
1-713
tf
Default: 'seconds'
InputName
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
1-714
tf
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-715
tf
OutputUnit
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
1-716
tf
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
SamplingGrid
When you display M, each entry in the array includes the corresponding
zeta and w values.
1-717
tf
M
M(:,:,1,1) [zeta=0.3, w=5] =
25
-------------s^2 + 3 s + 25
Default: []
Algorithms
See Also
Tutorials
How To
1-718
tfdata
Purpose
Syntax
[num,den] = tfdata(sys)
[num,den,Ts] = tfdata(sys)
[num,den,Ts,sdnum,sdden]=tfdata(sys)
[num,den,Ts,...]=tfdata(sys,J1,...,Jn)
Description
1-719
tfdata
You can access the remaining LTI properties of sys with get or by
direct referencing, for example,
sys.Ts
sys.variable
Examples
Example 1
Given the SISO transfer function
h = tf([1 1],[1 2 5])
the command
[num,den] = tfdata(H)
now returns two cell arrays with the numerator/denominator data for
each SISO entry. Use celldisp to visualize this data. Type
1-720
tfdata
celldisp(num)
num{2} =
0
Example 2
Extract the numerator, denominator and their standard deviations for
a 2-input, 1 output identified transfer function.
load iddata7
See Also
1-721
thiran
Purpose
Syntax
Description
Tips
Input
Arguments
tau
Sampling time.
Output
Arguments
sys
Examples
Discrete-time tf object.
sys1 = thiran(2.4, 1)
Transfer function:
0.004159 z^3 - 0.04813 z^2 + 0.5294 z + 1
----------------------------------------z^3 + 0.5294 z^2 - 0.04813 z + 0.004159
1-722
thiran
Sampling time: 1
The time delay is 2.4 s, and the sample time is 1 s. Therefore, sys1 is a
discrete-time transfer function of order 3.
Discretize a time delay that is an integer multiple of the target sample
time.
sys2 = thiran(10, 1)
Transfer function:
1
---z^10
Sampling time: 1
Algorithms
H ( z) =
aN z N + aN 1 z N 1 + + a1
a0 z N + a1 z N 1 + + aN
k : 1, 2, , N
References
See Also
c2d | pade | tf
1-723
timeoptions
Purpose
Syntax
P = timeoptions
P = timeoptions('cstprefs')
Description
1-724
Option
Description
TickLabel
Grid
XlimMode, YlimMode
Limit modes
Xlim, Ylim
Axes limits
IOGrouping
InputLabels, OutputLabels
InputVisible, OutputVisible
timeoptions
Option
Description
Normalize
Normalize responses
Specified as one of the following
strings: 'on' |'off'
Default: 'off'
SettleTimeThreshold
RiseTimeLimits
TimeUnits
1-725
timeoptions
Examples
See Also
1-726
totaldelay
Purpose
Syntax
td = totaldelay(sys)
Description
Examples
1
1
e2 s e1.5 s = e3.5 s
s
s
This is equivalent to assigning an I/O delay of 3.5 seconds to the original
model sys.
See Also
absorbDelay | hasdelay
1-727
tzero
Purpose
Syntax
z = tzero(sys)
z = tzero(A,B,C,D,E)
z = tzero( ___ ,tol)
[z,nrank] = tzero( ___ )
Description
model
dx
Ax Bu
dt
y Cx Du.
Tips
Input
Arguments
sys
1-728
tzero
A,B,C,D,E
dx
Ax Bu
dt
y Cx Du.
tzero does not scale the state-space matrices when you use the syntax z
= tzero(A,B,C,D,E). Use prescale if you want to scale the matrices
before using tzero.
Omit E to use E = I.
tol
Output
Arguments
1-729
tzero
Definitions
Invariant zeros
For a MIMO state-space model
dx
Ax Bu
dt
y Cx Du,
the invariant zeros are the complex values of s for which the rank of the
system matrix
A sE
C
B
D
drops from its normal value. (For explicit state-space models, E = I).
Transmission zeros
For a MIMO state-space model
dx
Ax Bu
dt
y Cx Du,
the transmission zeros are the complex values of s for which the rank of
the equivalent transfer function H(s) = D + C(sE A)1B drops from its
normal value. (For explicit state-space models, E = I.)
Transmission zeros are a subset of the invariant zeros. For minimal
realizations, the transmission zeros and invariant zeros are identical.
Examples
1-730
tzero
The output is a column vector listing the locations of the invariant zeros
of H. This output shows that H a has complex pair of invariant zeros.
Check whether the first invariant zero is a transmission zero of H.
If z(1) is a transmission zero of H, then H drops rank at s = z(1).
H1 = evalfr(H,z(1));
svd(H1)
ans =
1.5000
0.0000
H1 is the transfer function, H, evaluated at s = z(1). H1 has a zero
singular value, indicating that H drops rank at that value of s.
Therefore, z(1) is a transmission zero of H. A similar analysis shows
that z(2) is also a transmission zero.
1-731
tzero
unobservable states.
Scale the state-space matrices of gasf.
[A,B,C,D] = ssdata(prescale(gasf));
1-732
tzero
Algorithms
References
Alternatives
See Also
1-733
updateSystem
Purpose
Syntax
updateSystem(h,sys)
updateSystem(h,sys,N)
Description
Input
Arguments
h - Plot to update
plot handle
System from which to compute new response data for the response plot,
specified as a dynamic system model or model array.
sys must match the plotted system that it replaces in both I/O
dimensions and array dimensions. For example, suppose h refers to a
plot that displays the step responses of a 5-element vector of 2-input,
2-output systems. In this case, sys must also be a 5-element vector of
2-input, 2-output systems. The number of states in the elements of sys
need not match the number of states in the plotted systems.
1-734
updateSystem
To replace the impulse data of G3 with data from a new system, sys,
use the following command.
updateSystem(h,sys,3);
Examples
1-735
updateSystem
Update the step plot to display the second closed-loop system instead of
the first. The closed-loop system is the second response in the plot, so
specify the index value 2.
1-736
updateSystem
updateSystem(h,CL2,2);
Related
Examples
1-737
upsample
Purpose
Syntax
sysl = upsample(sys,L)
Description
The responses of models sys and sysl have the following similarities:
The time responses of sys and sysl match at multiples of Ts0.
The frequency responses of sys and sysl match up to the Nyquist
frequency / Ts0.
Note sysl has L times as many states as sys.
Examples
1-738
upsample
See Also
1-739
view (genmat)
Purpose
Syntax
view(M)
view(M,xvar)
view(M,xvar,yvar)
view(M,xvar,xdata)
view(M,xvar,xdata,yvar,ydata)
Description
matrix array, using xvar to name the X axis. This plot also uses the
values in xdata as the values along the X axis. Use this syntax when
M.SamplingGrid is empty.
1-740
view (genmat)
generalized matrix array, using xvar and yvar to name the X and Y
axes, respectively. This plot also uses the values in xdata and ydata
as values along the X and Y axes, respectively. Use this syntax when
M.SamplingGrid is empty.
Input
Arguments
string
string
1-741
view (genmat)
numeric vector
Examples
K , K 0 K1 K 2 K 3 .
[alpha,beta] = ndgrid(0:1:15,300:50:600);
F1 = alpha;
F2 = beta;
F3 = alpha.*beta;
K = gainsurf('K',1,F1,F2,F3);
K.SamplingGrid = struct('alpha',alpha,'beta',beta);
1-742
view (genmat)
1-743
view (genmat)
view automatically applies the axis labels and scaling stored in the
SamplingGrid property of the gain surface (see the genmat reference
page). If the SamplingGrid property is empty, the independent variable
1-744
view (genmat)
view(K,'beta','alpha')
1-745
view (genmat)
[alpha,beta] = ndgrid(0:1:15,300:50:600);
F1 = alpha;
F2 = beta;
F3 = alpha.*beta;
K = gainsurf('K',1,F1,F2,F3);
SG = struct('alpha',alpha,'beta',beta);
K.SamplingGrid = SG;
gainsurf initializes all gain surface coefficients to zero. For this
example, manually set the coefficients to nonzero values.
K.Blocks.K_1.Value = -0.015;
K.Blocks.K_2.Value = 0.02;
K.Blocks.K_3.Value = 0.01;
1-746
view (genmat)
view scales the X-axis using the beta values stored in the SamplingGrid
property of the gain surface. This plot is useful to visualize the full
range of gain variation due to one independent variable.
1-747
view (genmat)
variable axes. In addition, the independent variable values are just the
index values of the gain matrix. (For information about SamplingGrid,
see the genmat reference page). In this case, you can specify variable
names and values for the purpose of the plot.
Create a gain surface that is a bilinear function of two independent
variables, and .
[alpha,beta] = ndgrid(0:1:15,300:50:600);
F1 = alpha;
F2 = beta;
F3 = alpha.*beta;
K = gainsurf('K',1,F1,F2,F3);
gainsurf initializes all gain surface coefficients to zero. For this
example, manually set the coefficients to nonzero values.
K.Blocks.K_1.Value = -0.015;
K.Blocks.K_2.Value = 0.02;
K.Blocks.K_3.Value = 0.01;
1-748
view (genmat)
You can use any variable name and values that you like. The name and
value only label the axes and do not affect the gain values themselves,
which are stored in K. However, the vectors you supply for the variable
values must match the sampling dimensions of the gain surface. For
example, K is created using an 16-element vector for its first dimension.
Therefore, the vector you provide of values for that dimension must
also have 16 elements.
1-749
view (genmat)
See Also
Functions
1-750
genmatgainsurfgetValuesetBlockValue
xperm
Purpose
Syntax
sys = xperm(sys,P)
Description
Examples
load ltiexamples
ssF8
Velocity
AOA
-0.7
-0.0458
-12.2
-0.014
-0.2904
-0.562
AOA
-0.0057
-1.4
PitchAngle
PitchRate
Velocity
PitchAngle
b =
Elevator
PitchRate
Velocity
AOA
PitchAngle
Flaperon
-19.1
-3.1
-0.0119
-0.0096
-0.14
-0.72
c =
PitchRate
Velocity
AOA
FlightPath
-1
PitchAngle
1
Acceleration
0.733
1-751
xperm
d =
Elevator
FlightPath
Acceleration
Flaperon
0.0768
0.1134
Continuous-time model.
commands:
[y,P]=sort(ssF8.StateName);
sys=xperm(ssF8,P)
AOA
PitchAngle
PitchRate
Velocity
-1.4
-0.0057
-12.2
-0.7
-0.0458
-0.2904
-0.562
-0.014
PitchAngle
PitchRate
Velocity
b =
AOA
PitchAngle
PitchRate
Velocity
Elevator
Flaperon
-0.14
-0.72
-19.1
-3.1
-0.0119
-0.0096
c =
AOA
PitchAngle
PitchRate
-1
0.733
FlightPath
Acceleration
d =
Elevator
FlightPath
Acceleration
1-752
Flaperon
0.0768
0.1134
Velocity
xperm
Continuous-time model.
See Also
ss | dss
1-753
zero
Purpose
Syntax
z = zero(sys)
[z,gain] = zero(sys)
[z,gain] = zero(sysarr,J1,...,JN)
Description
Input
Arguments
sys
Output
Arguments
1-754
zero
Examples
H s
H = tf([4.2,0.25,-0.004],[1,9.6,17]);
[z,gain] = zero(H)
z =
-0.0726
0.0131
gain =
4.2000
The zero locations are expressed in radians per second, because the time
unit of the transfer function (H.TimeUnit) is seconds. Change the model
time units, and zero returns pole locations relative to the new unit.
H = chgTimeUnit(H,'minutes');
[z,gain] = zero(H)
z =
-4.3581
0.7867
gain =
4.2000
1-755
zero
Alternatives
See Also
1-756
zgrid
Purpose
Syntax
zgrid
zgrid(z,wn)
zgrid([],[])
Description
zgrid generates, for root locus and pole-zero maps, a grid of constant
damping factors from zero to one in steps of 0.1 and natural frequencies
from zero to in steps of /10, and plots the grid over the current axis.
If the current axis contains a discrete z-plane root locus diagram or
pole-zero map, zgrid draws the grid over the plot without altering the
current axis limits.
zgrid(z,wn) plots a grid of constant damping factor and natural
frequency lines for the damping factors and normalized natural
frequencies in the vectors z and wn, respectively. If the current axis
contains a discrete z-plane root locus diagram or pole-zero map,
zgrid(z,wn) draws the grid over the plot. The frequency lines for
unnormalized (true) frequencies can be plotted using
zgrid(z,wn/Ts)
Alternatively, you can select Grid from the right-click menu to generate
the same z-plane grid.
Examples
Plot z-plane grid lines on the root locus for the system
H ( z) =
2 z2 3.4 z + 1.5
z2 1.6 z + 0.8
by typing
H = tf([2 -3.4 1.5],[1 -1.6 0.8],-1)
1-757
zgrid
Transfer function:
2 z^2 - 3.4 z + 1.5
------------------z^2 - 1.6 z + 0.8
Sampling time: unspecified
See Also
1-758
zpk
Purpose
Syntax
sys = zpk(z,p,k)
sys = zpk(z,p,k,Ts)
sys = zpk(M)
sys = zpk(z,p,k,ltisys)
s = zpk('s')
z = zpk('z',Ts)
zsys = zpk(sys)
zsys = zpk(sys, 'measured')
zsys = zpk(sys, 'noise')
zsys = zpk(sys, 'augmented')
Description
h ( s) = k
( s z (1 ) ) ( s z ( 2 ) ) ( s z ( m ) )
( s p (1 ) ) ( s p ( 2 ) ) ( s p ( n ) )
1-759
zpk
The vectors z{i,j} and p{i,j} specify the zeros and poles of the
transfer function from input j to output i.
k(i,j) specifies the (scalar) gain of the transfer function from input
j to output i.
See below for a MIMO example.
sys = zpk(z,p,k,Ts) creates a discrete-time zero-pole-gain model
with sample time Ts (in seconds). Set Ts = -1 or Ts = [] to leave the
sample time unspecified. The input arguments z, p, k are as in the
continuous-time case.
sys = zpk(M) specifies a static gain M.
sys = zpk(z,p,k,ltisys) creates a zero-pole-gain model with
properties inherited from the LTI model ltisys (including the sample
time).
To create an array of zpk model objects, use a for loop, or use
multidimensional cell arrays for z and p, and a multidimensional array
for k.
Any of the previous syntaxes can be followed by property name/property
value pairs.
'PropertyName',PropertyValue
Each pair specifies a particular property of the model, for example, the
input names or the input delay time. For more information about the
properties of zpk model objects, see Properties on page 1-762. Note
that
sys = zpk(z,p,k,'Property1',Value1,...,'PropertyN',ValueN)
1-760
zpk
1-761
zpk
Variable
Selection
As for transfer functions, you can specify which variable to use in the
display of zero-pole-gain models. Available choices include s (default)
and p for continuous-time models, and z (default), z-1, q-1 (equivalent
to z-1), or q (equivalent to z) for discrete-time models. Reassign the
'Variable' property to override the defaults. Changing the variable
affects only the display of zero-pole-gain models.
Properties
System zeros.
The z property stores the transfer function zeros (the numerator roots).
For SISO models, z is a vector containing the zeros. For MIMO models
with Ny outputs and Nu inputs, z is a Ny-by-Nu cell array of vectors of the
zeros for each input/output pair.
1-762
zpk
System poles.
The p property stores the transfer function poles (the denominator
roots). For SISO models, p is a vector containing the poles. For MIMO
models with Ny outputs and Nu inputs, p is a Ny-by-Nu cell array of
vectors of the poles for each input/output pair.
k
System gains.
The k property stores the transfer function gains. For SISO models, k is
a scalar value. For MIMO models with Ny outputs and Nu inputs, k is a
Ny-by-Nu matrix storing the gains for each input/output pair.
DisplayFormat
1-763
zpk
DisplayName Value
Second-Order Factor
(Complex Root pair
R = ajb)
'roots'
(s R)
'frequency'
(1 s/0), where 0 = R
'time constant'
sw
z 1
;
Ts
R 1
,
Ts
1-764
zpk
Input delay for each input channel, specified as a numeric vector. For
continuous-time systems, specify input delays in the time unit stored
in the TimeUnit property. For discrete-time systems, specify input
delays in integer multiples of the sampling period Ts. For example,
InputDelay = 3 means a delay of three sampling periods.
For a system with Nu inputs, set InputDelay to an Nu-by-1 vector. Each
entry of this vector is a numerical value that represents the input delay
for the corresponding input channel.
You can also set InputDelay to a scalar value to apply the same delay
to all channels.
OutputDelay
1-765
zpk
1-766
zpk
'milliseconds'
'seconds'
'minutes'
'hours'
'days'
'weeks'
'months'
'years'
Changing this property changes the overall system behavior. Use
chgTimeUnit to convert between time units without modifying system
behavior.
Default: 'seconds'
InputName
1-767
zpk
Input channel units. Use InputUnit to keep track of input signal units.
For a single-input model, set InputUnit to a string. For a multi-input
model, set InputUnit to a cell array of strings. InputUnit has no effect
on system behavior.
Default: Empty string '' for all input channels
InputGroup
Input channel groups. The InputGroup property lets you assign the
input channels of MIMO systems into groups and refer to each group
by name. Specify input groups as a structure. In this structure, field
names are the group names, and field values are the input channels
belonging to each group. For example:
sys.InputGroup.controls = [1 2];
sys.InputGroup.noise = [3 5];
creates input groups named controls and noise that include input
channels 1, 2 and 3, 5, respectively. You can then extract the subsystem
from the controls inputs to all outputs using:
sys(:,'controls')
1-768
zpk
sys.OutputName = 'measurements';
Output channel groups. The OutputGroup property lets you assign the
output channels of MIMO systems into groups and refer to each group
by name. Specify output groups as a structure. In this structure, field
names are the group names, and field values are the output channels
belonging to each group. For example:
sys.OutputGroup.temperature = [1];
sys.InputGroup.measurement = [3 5];
1-769
zpk
sys('measurement',:)
Any text that you want to associate with the system. Set Notes to a
string or a cell array of strings.
Default: {}
UserData
Any type of data you wish to associate with system. Set UserData to
any MATLAB data type.
Default: []
SamplingGrid
1-770
zpk
When you display M, each entry in the array includes the corresponding
zeta and w values.
M
M(:,:,1,1) [zeta=0.3, w=5] =
25
-------------s^2 + 3 s + 25
Default: []
Examples
Example 1
Create the continuous-time SISO transfer function:
1-771
zpk
h ( s) =
2s
( s 1 + j ) ( s 1 j ) ( s 2)
Example 2
Specify the following one-input, two-output zero-pole-gain model:
z 0 .3
.
H ( z) =
2 ( z + 0 .5 )
( z 0 .1 + j ) ( z 0 .1 j )
To do this, enter:
z
p
k
H
=
=
=
=
{[] ; -0.5};
{0.3 ; [0.1+i 0.1-i]};
[1 ; 2];
zpk(z,p,k,-1);
% unspecified sample time
Example 3
Convert the transfer function
h = tf([-10 20 0],[1 7 20 28 19 5]);
1-772
zpk
---------------------(s+1)^3 (s^2 + 4s + 5)
Example 4
Create a discrete-time ZPK model from a rational expression in the
variable z.
z = zpk('z',0.1);
H = (z+.1)*(z+.2)/(z^2+.6*z+.09)
Example 5
Create a MIMO zpk model using cell arrays of zeros and poles.
Create the two-input, two-output zero-pole-gain model
H ( s) =
2
2 s 2s + 2
( s 1) ( s 2 ) ( s 3 )
3 ( s + 5)
( s + 1 )2
by entering:
Z = {[],-5;[1-i 1+i] []};
P = {0,[-1 -1];[1 2 3],[]};
1-773
zpk
Example 6
Extract the measured and noise components of an identified polynomial
model into two separate ZPK models. The former (measured component)
can serve as a plant model while the latter can serve as a disturbance
model for control system design.
load icEngine
z = iddata(y,u,0.04);
nb = 2; nf = 2; nc = 1; nd = 3; nk = 3;
sys = bj(z, [nb nc nd nf nk]);
sys is a model of the form, y(t) = B/F u(t) + C/D e(t), where B/F
represents the measured component and C/D the noise component.
sysMeas = zpk(sys, 'measured')
Algorithms
zpk uses the MATLAB function roots to convert transfer functions and
the functions zero and pole to convert state-space models.
See Also
1-774
zpkdata
Purpose
Syntax
[z,p,k] = zpkdata(sys)
[z,p,k,Ts] = zpkdata(sys)
[z,p,k,Ts,covz,covp,covk] = zpkdata(sys)
Description
forces zpkdata to return the zeros and poles directly as column vectors
rather than as cell arrays (see example below).
[z,p,k,Ts] = zpkdata(sys) also returns the sample time Ts.
[z,p,k,Ts,covz,covp,covk] = zpkdata(sys) also returns the
covariances of the zeros, poles and gain of the identified model sys.
covz is a cell array such that covz{ky,ku} contains the covariance
information about the zeros in the vector z{ky,ku}. covz{ky,ku}
is a 3-D array of dimension 2-by-2-by-Nz, where Nz is the length of
z{ky,ku}, so that the (1,1) element is the variance of the real part, the
(2,2) element is the variance of the imaginary part, and the (1,2) and
(2,1) elements contain the covariance between the real and imaginary
parts. covp has a similar relationship to p.covk is a matrix containing
the variances of the elements of k.
1-775
zpkdata
You can access the remaining LTI properties of sys with get or by
direct referencing, for example,
sys.Ts
sys.inputname
Examples
Example 1
Given a zero-pole-gain model with two outputs and one input
H = zpk({[0];[-0.5]},{[0.3];[0.1+i 0.1-i]},[1;2],-1)
Zero/pole/gain from input to output...
z
#1: ------(z-0.3)
#2:
2 (z+0.5)
------------------(z^2 - 0.2z + 1.01)
To access the zeros and poles of the second output channel of H, get the
content of the second cell in z and p by typing
1-776
zpkdata
z{2,1}
ans =
-0.5000
p{2,1}
ans =
0.1000+ 1.0000i
0.1000- 1.0000i
Example 2
Extract the ZPK matrices and their standard deviations for a 2-input, 1
output identified transfer function.
load iddata7
See Also
1-777
zpkdata
1-778
2
Block Reference
LTI System
Purpose
Description
The LTI System block imports linear system model objects into the
Simulink environment.
The imported system must be proper. State-space models are always
proper. SISO transfer functions or zero-pole-gain models are proper if
the degree of their numerator is less than or equal to the degree of their
denominator. MIMO transfer functions are proper if all their SISO
entries are proper.
2-2
LTI System
Dialog
Box
2-3