connecting models -凯发k8网页登录
this example shows how to model interconnections of lti systems, from simple series and parallel connections to complex block diagrams.
overview
control system toolbox™ provides a number of functions to help you build networks of lti models. these include functions to perform
series and parallel connections (
series
andparallel
)feedback connections (
feedback
andlft
)input and output concatenations (
[ , ]
,[ ; ]
, andappend
)general block-diagram building (
connect
).
these functions can handle any combination of model representations. for illustration purposes, create the following two siso transfer function models:
h1 = tf(2,[1 3 0])
h1 = 2 --------- s^2 3 s continuous-time transfer function.
h2 = zpk([],-5,5)
h2 = 5 ----- (s 5) continuous-time zero/pole/gain model.
series connection
use the *
operator or the series
function to connect lti models in series, for example:
h = h2 * h1
h = 10 ------------- s (s 5) (s 3) continuous-time zero/pole/gain model.
or equivalently
h = series(h1,h2);
parallel connection
use the
operator or the parallel
function to connect lti models in parallel, for example:
h = h1 h2
h = 5 (s 2.643) (s 0.7566) ---------------------- s (s 3) (s 5) continuous-time zero/pole/gain model.
or equivalently
h = parallel(h1,h2);
feedback connections
the standard feedback configuration is shown below:
to build a model of the closed-loop transfer from u
to y
, type
h = feedback(h1,h2)
h = 2 (s 5) -------------------------------- (s 5.663) (s^2 2.337s 1.766) continuous-time zero/pole/gain model.
note that feedback
assumes negative feedback by default. to apply positive feedback, use the following syntax:
h = feedback(h1,h2, 1);
you can also use the lft
function to build the more general feedback interconnection sketched below.
concatenating inputs and outputs
you can concatenate the inputs of the two models h1
and h2
by typing
h = [ h1 , h2 ]
h = from input 1 to output: 2 ------- s (s 3) from input 2 to output: 5 ----- (s 5) continuous-time zero/pole/gain model.
the resulting model has two inputs and corresponds to the interconnection:
similarly, you can concatenate the outputs of h1
and h2
by typing
h = [ h1 ; h2 ]
h = from input to output... 2 1: ------- s (s 3) 5 2: ----- (s 5) continuous-time zero/pole/gain model.
the resulting model h
has two outputs and one input and corresponds to the following block diagram:
finally, you can append the inputs and outputs of two models using:
h = append(h1,h2)
h = from input 1 to output... 2 1: ------- s (s 3) 2: 0 from input 2 to output... 1: 0 5 2: ----- (s 5) continuous-time zero/pole/gain model.
the resulting model h
has two inputs and two outputs and corresponds to the block diagram:
you can use concatenation to build mimo models from elementary siso models, for example:
h = [h1 , -tf(10,[1 10]) ; 0 , h2 ]
h = from input 1 to output... 2 1: ------- s (s 3) 2: 0 from input 2 to output... -10 1: ------ (s 10) 5 2: ----- (s 5) continuous-time zero/pole/gain model.
sigma(h), grid
building models from block diagrams
you can use combinations of the functions and operations introduced so far to construct models of simple block diagrams. for example, consider the following block diagram:
with the following data for the blocks f
, c
, g
, s
:
s = tf('s');
f = 1/(s 1);
g = 100/(s^2 5*s 100);
c = 20*(s^2 s 60)/s/(s^2 40*s 400);
s = 10/(s 10);
you can compute the closed-loop transfer t
from r
to y
as
t = f * feedback(g*c,s); step(t), grid
for more complicated block diagrams, the connect
function provides a systematic and simple way to wire blocks together. to use connect
, follow these steps:
define all blocks in the diagram, including summation blocks
name all block input and output channels
select the block diagram i/os from the list of block i/os.
for the block diagram above, these steps amount to:
sum1 = sumblk('e = r - y'); sum2 = sumblk('u = uc uf'); % define block i/os ("u" and "y" are shorthand for "inputname" and "outputname") f.u = 'r'; f.y = 'uf'; c.u = 'e'; c.y = 'uc'; g.u = 'u'; g.y = 'ym'; s.u = 'ym'; s.y = 'y'; % compute transfer r -> ym t = connect(f,c,g,s,sum1,sum2,'r','ym'); step(t), grid
precedence rules
when connecting models of different types, the resulting model type is determined by the precedence rule
frd > ss > zpk > tf > pid
this rule states that frd has highest precedence, followed by ss, zpk, tf, and pid has the lowest precedence. for example, in the series connection:
h1 = ss(-1,2,3,0); h2 = tf(1,[1 0]); h = h2 * h1;
h2
is automatically converted to the state-space representation and the result h
is a state-space model:
class(h)
ans = 'ss'
because the ss and frd representations are best suited for system interconnections, it is recommended that you convert at least one of the models to ss or frd to ensure that all computations are performed using one of these two representations. one exception is when using connect
which automatically performs such conversion and always returns a state-space or frd model of the block diagram.