Next: tf2sys, Previous: fir2sys, Up: sysinterface

— 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

abcd- usual state space matrices.
default:

d= zero matrixtsam- sampling rate. Default: tsam = 0 (continuous system)
nnz- number of continuous, discrete states in the system
If

tsamis 0, n =`rows`

(a), nz = 0.If

tsamis 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 statesinname- 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

tsamis 0, outlist = [].If

tsamis greater than 0, outlist = 1:`rows`

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

`sys2ss`

returns a vectorydwhereyd(outlist) = 1; all other entries ofydare 0.

Outputsoutsys= system data structure

System partitioningSuppose 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: d/dt xc(t) = acc*xc(t) + acd*xd(k*tsam) + bc*u(t)

xd((k+1)*tsam) = adc*xc(k*tsam) + add*xd(k*tsam) + bd*u(k*tsam)

yc(t) = ccc*xc(t) + ccd*xd(k*tsam) + dc*u(t)

yd(k*tsam) = cdc*xc(k*tsam) + cdd*xd(k*tsam) + dd*u(k*tsam)

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.)

Exampleoctave: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 0Notice 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.

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

abcd- State space matrices for
sys.tsam- Sampling time of
sys(0 if continuous).nnz- Number of continuous, discrete states (discrete states come last in state vector
x).stnameinnameoutname- Signal names (lists of strings); names of states, inputs, and outputs, respectively.
yd- Binary vector;
yd(ii) is 1 if outputy(ii) is discrete (sampled); otherwiseyd(ii) is 0.

Exampleoctave: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