[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

29.2 System Construction and Interface Functions

Construction and manipulations of the OCST system data structure (see section System Data Structure) requires attention to many details in order to ensure that data structure contents remain consistent. Users are strongly encouraged to use the system interface functions in this section. Functions for the formatted display in of system data structures are given in System display functions.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

29.2.1 Finite impulse response system interface functions

Function File: fir2sys (num, tsam, inname, outname)

construct a system data structure from FIR description

Inputs

num

vector of coefficients of the SISO FIR transfer function

tsam

sampling time (default: 1)

inname

name of input signal; may be a string or a list with a single entry.

outname

name of output signal; may be a string or a list with a single entry.

Output

sys

system data structure

Example

 
octave:1> sys = fir2sys([1 -1 2 4],0.342,\
> "A/D input","filter output");
octave:2> sysout(sys)
Input(s)
        1: A/D input

Output(s):
        1: filter output (discrete)

Sampling interval: 0.342
transfer function form:
1*z^3 - 1*z^2 + 2*z^1 + 4
-------------------------
1*z^3 + 0*z^2 + 0*z^1 + 0

Function File: [c, tsam, input, output] = sys2fir (sys)

Extract FIR data from system data structure; see fir2sys for parameter descriptions.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

29.2.2 State space system interface functions

Function File: ss (a, b, c, d, tsam, n, nz, stname, inname, outname, outlist)

Create system structure from state-space data. May be continous, discrete, or mixed (sampled data)

Inputs

a
b
c
d

usual state space matrices.

default: d = zero matrix

tsam

sampling rate. Default: tsam = 0 (continuous system)

n
nz

number of continuous, discrete states in the system

If tsam is 0, n = rows(a), nz = 0.

If tsam is greater than zero, n = 0, nz = rows(a)

see below for system partitioning

stname

cell array of strings of state signal names

default (stname=[] on input): x_n for continuous states, xd_n for discrete states

inname

cell array of strings of input signal names

default (inname = [] on input): u_n

outname

cell array of strings of input signal names

default (outname = [] on input): y_n

outlist

list of indices of outputs y that are sampled

If tsam is 0, outlist = [].

If tsam is greater than 0, outlist = 1:rows(c).

Unlike states, discrete/continous outputs may appear in any order.

sys2ss returns a vector yd where yd(outlist) = 1; all other entries of yd are 0.

Outputs outsys = system data structure

System partitioning

Suppose for simplicity that outlist specified that the first several outputs were continuous and the remaining outputs were discrete. Then the system is partitioned as

 
x = [ xc ]  (n x 1)
    [ xd ]  (nz x 1 discrete states)
a = [ acc acd ]  b = [ bc ]
    [ adc add ]      [ bd ]
c = [ ccc ccd ]  d = [ dc ]
    [ cdc cdd ]      [ dd ]

    (cdc = c(outlist,1:n), etc.)

with dynamic equations:

Signal partitions

 
        | continuous      | discrete               |
----------------------------------------------------
states  | stname(1:n,:)   | stname((n+1):(n+nz),:) |
----------------------------------------------------
outputs | outname(cout,:) | outname(outlist,:)     |
----------------------------------------------------

where cout is the list of in 1:rows(p) that are not contained in outlist. (Discrete/continuous outputs may be entered in any order desired by the user.)

Example

 
octave:1> a = [1 2 3; 4 5 6; 7 8 10];
octave:2> b = [0 0 ; 0 1 ; 1 0];
octave:3> c = eye (3);
octave:4> sys = ss (a, b, c, [], 0, 3, 0, {"volts", "amps", "joules"});
octave:5> sysout(sys);
Input(s)
        1: u_1
        2: u_2

Output(s):
        1: y_1
        2: y_2
        3: y_3

state-space form:
3 continuous states, 0 discrete states
State(s):
        1: volts
        2: amps
        3: joules

A matrix: 3 x 3
   1   2   3
   4   5   6
   7   8  10
B matrix: 3 x 2
  0  0
  0  1
  1  0
C matrix: 3 x 3
  1  0  0
  0  1  0
  0  0  1
D matrix: 3 x 3
  0  0
  0  0
  0  0

Notice that the D matrix is constructed by default to the correct dimensions. Default input and output signals names were assigned since none were given.

Function File: [a, b, c, d, tsam, n, nz, stname, inname, outname, yd] = sys2ss (sys)

Extract state space representation from system data structure.

Input

sys

System data structure.

Outputs

a
b
c
d

State space matrices for sys.

tsam

Sampling time of sys (0 if continuous).

n
nz

Number of continuous, discrete states (discrete states come last in state vector x).

stname
inname
outname

Signal names (lists of strings); names of states, inputs, and outputs, respectively.

yd

Binary vector; yd(ii) is 1 if output y(ii) is discrete (sampled); otherwise yd(ii) is 0.

A warning massage is printed if the system is a mixed continuous and discrete system.

Example

 
octave:1> sys=tf2sys([1 2],[3 4 5]);
octave:2> [a,b,c,d] = sys2ss(sys)
a =
   0.00000   1.00000
  -1.66667  -1.33333
b =
  0
  1
c = 0.66667  0.33333
d = 0

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

29.2.3 Transfer function system interface functions

Function File: tf2sys (num, den, tsam, inname, outname)

Build system data structure from transfer function format data.

Inputs

num
den

Coefficients of numerator/denominator polynomials.

tsam

Sampling interval; default: 0 (continuous time).

inname
outname

Input/output signal names; may be a string or cell array with a single string entry.

Output

sys

System data structure.

Example

 
octave:1> sys=tf2sys([2 1],[1 2 1],0.1);
octave:2> sysout(sys)
Input(s)
        1: u_1
Output(s):
        1: y_1 (discrete)
Sampling interval: 0.1
transfer function form:
2*z^1 + 1
-----------------
1*z^2 + 2*z^1 + 1

Function File: [num, den, tsam, inname, outname] = sys2tf (sys)

Extract transfer function data from a system data structure.

See tf for parameter descriptions.

Example

 
octave:1> sys=ss([1 -2; -1.1,-2.1],[0;1],[1 1]);
octave:2> [num,den] = sys2tf(sys)
num = 1.0000  -3.0000
den = 1.0000   1.1000  -4.3000

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

29.2.4 Zero-pole system interface functions

Function File: zp2sys (zer, pol, k, tsam, inname, outname)

Create system data structure from zero-pole data.

Inputs

zer

Vector of system zeros.

pol

Vector of system poles.

k

Scalar leading coefficient.

tsam

Sampling period; default: 0 (continuous system).

inname
outname

Input/output signal names (lists of strings).

Output

sys

System data structure.

Example

 
octave:1> sys=zp2sys([1 -1],[-2 -2 0],1);
octave:2> sysout(sys)
Input(s)
        1: u_1
Output(s):
        1: y_1
zero-pole form:
1 (s - 1) (s + 1)
-----------------
s (s + 2) (s + 2)

Function File: [zer, pol, k, tsam, inname, outname] = sys2zp (sys)

Extract zero/pole/leading coefficient information from a system data structure.

See zp for parameter descriptions.

Example

 
octave:1> sys=ss([1 -2; -1.1,-2.1],[0;1],[1 1]);
octave:2> [zer,pol,k] = sys2zp(sys)
zer = 3.0000
pol =
  -2.6953
   1.5953
k = 1

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

29.2.5 Data structure access functions

Function File: syschnames (sys, opt, list, names)

Superseded by syssetsignals.

Function File: syschtsam (sys, tsam)

This function changes the sampling time (tsam) of the system. Exits with an error if sys is purely continuous time.

Function File: [n, nz, m, p, yd] = sysdimensions (sys, opt)

return the number of states, inputs, and/or outputs in the system sys.

Inputs

sys

system data structure

opt

String indicating which dimensions are desired. Values:

"all"

(default) return all parameters as specified under Outputs below.

"cst"

return n= number of continuous states

"dst"

return n= number of discrete states

"in"

return n= number of inputs

"out"

return n= number of outputs

Outputs

n

number of continuous states (or individual requested dimension as specified by opt).

nz

number of discrete states

m

number of system inputs

p

number of system outputs

yd

binary vector; yd(ii) is nonzero if output ii is discrete. yd(ii) = 0 if output ii is continous

Function File: [stname, inname, outname, yd] = sysgetsignals (sys)
Function File: siglist = sysgetsignals (sys, sigid)
Function File: signame = sysgetsignals (sys, sigid, signum, strflg)

Get signal names from a system

Inputs

sys

system data structure for the state space system

sigid

signal id. String. Must be one of

"in"

input signals

"out"

output signals

"st"

stage signals

"yd"

value of logical vector yd

signum

index(indices) or name(s) or signals; see sysidx

strflg

flag to return a string instead of a cell array; Values:

0

(default) return a cell array (even if signum specifies an individual signal)

1

return a string. Exits with an error if signum does not specify an individual signal.

Outputs

• If sigid is not specified:
stname
inname
outname

signal names (cell array of strings); names of states, inputs, and outputs, respectively.

yd

binary vector; yd(ii) is nonzero if output ii is discrete.

• If sigid is specified but signum is not specified:
sigid="in"

siglist is set to the cell array of input names.

sigid="out"

siglist is set to the cell array of output names.

sigid="st"

siglist is set to the cell array of state names.

stage signals

sigid="yd"

siglist is set to logical vector indicating discrete outputs; siglist(ii) = 0 indicates that output ii is continuous (unsampled), otherwise it is discrete.

• If the first three input arguments are specified:

signame is a cell array of the specified signal names (sigid is "in", "out", or "st"), or else the logical flag indicating whether output(s) signum is(are) discrete (sigval=1) or continuous (sigval=0).

Examples (From sysrepdemo)

 
octave> sys=ss(rand(4),rand(4,2),rand(3,4));
octave># get all signal names
octave> [Ast,Ain,Aout,Ayd] = sysgetsignals(sys)
Ast =
(
  [1] = x_1
  [2] = x_2
  [3] = x_3
  [4] = x_4
)
Ain =
(
  [1] = u_1
  [2] = u_2
)
Aout =
(
  [1] = y_1
  [2] = y_2
  [3] = y_3
)
Ayd =

  0  0  0
octave> # get only input signal names:
octave> Ain = sysgetsignals(sys,"in")
Ain =
(
  [1] = u_1
  [2] = u_2
)
octave> # get name of output 2 (in cell array):
octave> Aout = sysgetsignals(sys,"out",2)
Aout =
(
  [1] = y_2
)
octave> # get name of output 2 (as string):
octave> Aout = sysgetsignals(sys,"out",2,1)
Aout = y_2

Function File: sysgettype (sys)

return the initial system type of the system

Input

sys

System data structure.

Output

systype

String indicating how the structure was initially constructed. Values: "ss", "zp", or "tf".

FIR initialized systems return systype="tf".

Function File: syssetsignals (sys, opt, names, sig_idx)

change the names of selected inputs, outputs and states.

Inputs

sys

System data structure.

opt

Change default name (output).

"out"

Change selected output names.

"in"

Change selected input names.

"st"

Change selected state names.

"yd"

Change selected outputs from discrete to continuous or from continuous to discrete.

names
opt = "out", "in", "st"

string or string array containing desired signal names or values.

opt = "yd"

To desired output continuous/discrete flag. Set name to 0 for continuous, or 1 for discrete.

sig_idx

indices or names of outputs, yd, inputs, or states whose respective names/values should be changed.

Default: replace entire cell array of names/entire yd vector.

Outputs

retsys

sys with appropriate signal names changed (or yd values, where appropriate).

Example

 
octave:1> sys=ss([1 2; 3 4],[5;6],[7 8]);
octave:2> sys = syssetsignals(sys,"st",str2mat("Posx","Velx"));
octave:3> sysout(sys)
Input(s)
        1: u_1
Output(s):
        1: y_1
state-space form:
2 continuous states, 0 discrete states
State(s):
        1: Posx
        2: Velx
A matrix: 2 x 2
  1  2
  3  4
B matrix: 2 x 1
  5
  6
C matrix: 1 x 2
  7  8
D matrix: 1 x 1
0

Function File: sysupdate (sys, opt)

Update the internal representation of a system.

Inputs

sys:

system data structure

opt

string:

"tf"

update transfer function form

"zp"

update zero-pole form

"ss"

update state space form

"all"

all of the above

Outputs

retsys

Contains union of data in sys and requested data. If requested data in sys is already up to date then retsys=sys.

Conversion to tf or zp exits with an error if the system is mixed continuous/digital.

Function File: [systype, nout, nin, ncstates, ndstates] = minfo (inmat)

Determines the type of system matrix. inmat can be a varying, a system, a constant, and an empty matrix.

Outputs

systype

Can be one of: varying, system, constant, and empty.

nout

The number of outputs of the system.

nin

The number of inputs of the system.

ncstates

The number of continuous states of the system.

ndstates

The number of discrete states of the system.

Function File: sysgettsam (sys)

Return the sampling time of the system sys.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

29.2.6 Data structure internal functions


[ < ] [ > ]   [ << ] [ Up ] [ >> ]

This document was generated on July, 20 2006 using texi2html 1.76.