A digital state-space model is normally written mathematically as
where
Note that all four matrices may change each sample instant to implement a general time-varying linear system.
A FAUST example for the general linear state-space model is shown in Fig.19. The FAUST-generated block diagram is shown in Fig.20.
Since a state-space model can implement any th-order linear system with inputs and outputs, all we have to do is come up with the matrix entries and use the general state-space formulation in FAUST given in Fig.19.
Here are the steps for finding the state-space matrices:
A simple example for trying out and checking this process can be found by starting at step 3 of ``Converting to State-Space Form by Hand'' [11].^{24} The details appear below in §A.1. Also be aware of the matlab function tf2ss for converting a transfer function to state-space form.
// General Linear State-Space Model Example import("stdfaust.lib"); p = 2; // number of inputs q = 3; // number of outputs N = 5; // number of states A = matrix(N,N); // state transition matrix B = matrix(N,p); // input-to-states matrix C = matrix(q,N); // states-to-output matrix D = matrix(q,p); // direct-term matrix, bypassing state matrix(M,N) = tgroup("Matrix: %M x %N", par(in, N, _) <: par(out, M, mixer(N, out))) with { fader(in) = ba.db2linear(vslider("Input %in", -10, -96, 4, 0.1)); mixer(N,out) = hgroup("Output %out", par(in, N, *(fader(in)) ) :> _ ); }; Bd = par(i,p,mem) : B; // input delay needed for conventional definition vsum(N) = si.bus(2*N) :> si.bus(N); // vector sum of two N-vectors impulse = 1-1'; // For zero initial state, set impulse = 0 or simplify code x0 = par(i,N,i*impulse); // initial state = (0,1,2,3,...,N-1) system = si.bus(p) <: D, (Bd : vsum(N)~(A), x0 : vsum(N) : C) :> si.bus(q); process = system; |