Transcription of State Space Models - Stanford University
1 MUS420 Introduction to Linear State Space ModelsJulius O. Smith III for Computer Research in Music and Acoustics (CCRMA)Department of Music, Stanford UniversityStanford, California 94305 February 5, 2019 Outline State Space Models Linear State Space Formulation Markov Parameters (Impulse Response) Transfer Function Difference Equations to State Space Models Similarity Transformations Modal Representation (Diagonalization) Matlab Examples1 State Space ModelsEquations of motionfor any physical system may beconveniently formulated in terms of itsstatex(t):ftInput Forcesu(t)RModel Statex(t) x(t) x(t) =ft[x(t), u(t)]wherex(t) =stateof the system at timetu(t) =vector ofexternal inputs(typically driving forces)ft=general function mapping the current statex(t)andinputsu(t)to the State time-derivative x(t) The functionftmay be time-varying, in general This potentially nonlinear time-varying model isextremely general (but causal) Even thehuman braincan be modeled in this form2 State - Space History1.
2 Classicphase-spacein physics (Gibbs 1901)System State = point inposition-momentum space2. Digital computer (1950s)3. Finite State Machines (Mealy and Moore, 1960s)4. Finite Automata5. State - Space Models of Linear Systems6. Reference:Linear system theory: The State Zadeh and DesoerKrieger, 19793 Key Property of State VectorThe key property of the State vectorx(t)in the statespace formulation is that itcompletely determines thesystem at timet Future states depend only on the current statex(t)and on any inputsu(t)at timetand beyond All past states and the entire input history are summarized by the current statex(t) Statex(t)includes all memory of the system4 Force-Driven Mass ExampleConsiderf=mafor the force-driven mass: Since the massmis constant, we can usemomentump(t) =m v(t)in place of velocity (more fundamental,since momentum isconserved) x(t0)andp(t0)(orv(t0)) define thestateof the massmat timet0 In the absence of external forcesf(t), all future statesarepredictablefrom the State at timet0:p(t) =p(t0)(conservation of momentum)x(t) =x(t0) +1mZtt0p( )d , t t0 External forcesf(t)drive the stateto arbitrary pointsin State Space .
3 P(t) =p(t0) +Ztt0f( )d , t t0, p(t) =m v(t)x(t) =x(t0) +1mZtt0p( )d , t t05 Forming OutputsAny systemoutputis some function of the State , andpossibly the input (directly):y(t) =ot[x(t), u(t)]ftInput Forcesu(t)RModel Statex(t) x(t)y(t)otUsually the output is alinear combinationof statevariables and possibly the current input:y(t) =Cx(t) +Du(t)whereCandDare constant matrices oflinear-combination coefficients6 Numerical IntegrationRecall the general State - Space model in continuous time: x(t) =ft[x(t), u(t)]An approximate discrete-time numerical solution isx(tn+Tn) =x(tn) +Tnftn[x(tn), u(tn)]forn= 0,1,2, ..(Forward Euler)Letgtn[x(tn), u(tn)] =x(tn) +Tnftn[x(tn), u(tn)]:u(tn)x(tn)gtx(tn+Tn)z Tn This is a simple example ofnumerical integrationforsolving the ODE ODE can be nonlinear and/or time-varying The sampling intervalTnmay be fixed or adaptive7 State DefinitionWe need astate variablefor the amplitude of eachphysical degree of freedomExamples: Ideal Mass:Energy=12mv2 State variable=v(t)Note that in 3D we get three State variables(vx, vy, vz) Ideal Spring:Energy=12kx2 State variable=x(t) Inductor: Analogous to mass, socurrent Capacitor: Analogous to spring, socharge(or voltage = charge/capacitance) Resistors and dashpots need no State variablesassigned they arestateless(no memory )8 State - Space Model of a Force-Driven MassFor the simple example of a massmdriven by externalforcefalong thexaxis.
4 F(t)x= 0v(t)m There is only one energy-storage element (the mass),and it stores energy in the form ofkinetic energy Therefore, we should choose the State variable to bevelocityv= x(or momentump=mv=m x) Newton sf=mareadily gives the State -spaceformulation: v=1mfor p=f This is a first-order system (no vector needed)9 Force-Driven Mass ReconsideredWhy not includepositionx(t)as well as velocityv(t)inthe State - Space model for the force-driven mass? x(t) v(t) = 0 10 0 x(t)v(t) + 01/m f(t)We might expect this because we know from before thatthe complete physical State of a mass consists of itsvelocityvandpositionx!10 Force-Driven Mass Reconsidered and Dismissed Positionxdoes not affect stored energyEm=12m v2 Velocityv(t)is the onlyenergy-storing degree offreedom Only velocityv(t)is needed as a State variable The initial positionx(0)can be kept on the side toenable computation of the complete State inposition-momentum Space :x(t) =x(0) +Zt0v( )d In other words, the position can be derived from thevelocity history without knowing the force history Note that the external forcef(t)can only drive v(t).
5 It cannot drive x(t)directly: x(t) v(t) = 0 10 0 x(t)v(t) + 01/m f(t)11 State Variable Summary State variable =physical amplitudefor someenergy-storing degree of freedom Mechanical Systems: State variable for each ideal spring(linear or rotational) point mass(or moment of inertia)times the number of dimensions in which it can move RLC Electric Circuits: State variable for eachcapacitorandinductor In Discrete-Time: State variable for eachunit-sample delay Continuous- or Discrete-Time:Dimensionality of State - Space =orderof the system(LTI systems)12 Discrete-Time Linear State SpaceModelsFor linear, time-invariant systems, a discrete-timestate- Space modellooks like avector first-orderfinite-differencemodel:x(n+ 1) =Ax(n) +Bu(n)y(n) =Cx(n) +Du(n)where x(n) RN= State vectorat timen u(n) =p 1vector of inputs y(n) =q 1output vector A=N Nstate transition matrix B=N pinput coefficient matrix C=q Noutput coefficient matrix D=q pdirect path coefficient matrixThe State - Space representation is especially powerful for multi-input, multi-output(MIMO) linear systems time-varyinglinear systems(every matrix can have a time subscriptn)13 Zero- State Impulse Response(Markov Parameters)Linear State - Space Model:y(n) =Cx(n) +Du(n)x(n+ 1) =Ax(n) +Bu(n)The zero-stateimpulse responseof a State - Space model iseasily found by direct calculation: Letx(0) = 0andu=Ip (n) =diag( (n).)
6 , (n)). Thenh(0) =Cx(0)B+D Ip (0) =Dx(1) =Ax(0) +B Ip (0) =Bh(1) =CBx(2) =Ax(1) +B (1) =ABh(2) =CABx(3) =Ax(1) +B (1) =A2Bh(3) = (n) =CAn 1B, n >014 Zero- State Impulse Response (MarkovParameters)Thus, the impulse response of the State - Space modelcan be summarized ash(n) =(D,n= 0 CAn 1B, n >0 Initial statex(0)assumed to be0 Input impulse isu=Ip (n) =diag( (n), .. , (n)) Each impulse-response sample h(n)is ap qmatrix, in general The impulse-response termsCAnBforn 0arecalledMarkov parameters15 Linear State - Space ModelTransfer Function Recall the linear State - Space model:y(n) =Cx(n) +Du(n)x(n+ 1) =Ax(n) +Bu(n)and its impulse response h(n) =(D,n= 0 CAn 1B, n >0 Thetransfer functionis theztransform of theimpulse response:H(z) = Xn=0h(n)z n=D+ Xn=1 CAn 1B z n=D+z 1C" Xn=0 z 1A n#BThe closed-form sum of a matrix geometric seriesgivesH(z) =D+C(zI A) 1B(ap qmatrixof rational polynomials inz)16 If there arepinputs andqoutputs, thenH(z)is ap qtransfer-function matrix(or matrix transfer function ) Given transfer-function coefficients, many digital filterrealizationsare possible (different computingstructures)Example.)
7 (p= 3,q= 2)H(z) = z 11 z 11 11 +z 12 + 3z 11 11 +z 11 z 1(1 z 1)2(1 1)(1 1) 17 System PolesAbove, we found the transfer function to beH(z) =D+C(zI A) 1 BThe poles ofH(z)are the same as those ofHp(z) = (zI A) 1 ByCramer s rulefor matrix inversion, the denominatorpolynomial for(zI A) 1is given by thedeterminant:d(z) =|zI A|where|Q|denotes thedeterminantof the square matrixQ(also written asdet(Q).) In linear algebra, the polynomiald(z) =|zI A|iscalled thecharacteristic polynomialfor the matrixA The roots of the characteristic polynomial are calledtheeigenvaluesofA Thus, theeigenvaluesof the State transition matrixAare the systempoles Eachmode of vibrationgives rise to a pole pair18 Initial-Condition ResponseGoing back to the time domain, we have the lineardiscrete-time State - Space modely(n) =Cx(n) +Du(n)x(n+ 1) =Ax(n) +Bu(n)and its impulse response h(n) =(D,n= 0 CAn 1B, n >0 Given zero inputs and initial statex(0)6= 0, we getyx(n) =CAnx(0), n= 0,1,2.)
8 Bysuperposition(for LTI systems), thecompleteresponseof a linear system is given by the sum of itsforced response(such as the impulse response) and itsinitial-condition response19 Difference Equation to State Space FormA digital filter is often specified by itsdifference equation(Direct Form I). Second-order example:y(n) =u(n)+2u(n 1)+3u(n 2) 12y(n 1) 13y(n 2)Everynth orderdifference equationcan be reformulatedas afirst order vectordifference equation called the State Space (or State variable ) representation:x(n+ 1) =Ax(n) +Bu(n)y(n) =Cx(n) +Du(n)For the above example, we have, as we ll show,A = 12 131 0 ( State transition matrix)B = 10 (matrix routing input to State variables)C = 3/28/3 (output linear-combination matrix)D = 1(direct feedforward coefficient)20 Converting to State - Space Form by Hand1. First, determine the filter transfer functionH(z). Inthe example, the transfer function can be written, byinspection, asH(z) =1 + 2z 1+ 3z 21 +12z 1+13z 22.
9 Ifh(0)6= 0, we must pull out the parallel delay-freepath:H(z) =d0+b1z 1+b2z 21 +12z 1+13z 2 Obtaining a common denominator and equatingnumerator coefficients yieldsd0= 1b1= 2 12=32b2= 3 13=83 The same result is obtained using long or syntheticdivision213. Next, draw the strictly causal part indirect form II, asshown below:x(n)y(n) 1/3x2(n)x1(n)z 1z 13/28/31 1/2x1(n+ 1)It is important that the filter representation becanonical with respect to delay, , the number ofdelay elements equals the order of the filter4. Assign a State variable to the output of each delayelement (see figure)5. Write down the State - Space representation byinspection. (Try it and compare to answer above.)22 Matlab Conversion from Direct-Form toState- Space FormMatlab has extensive support for State - Space Models ,such as tf2ss- transfer-function to State - Space conversion ss2tf- State - Space to transfer-function conversionNote that these utilities are documented primarily forcontinuous-time systems, but they are also used fordiscrete-time s repeat the previous example using Matlab:23 Previous Example Using Matlab>> num = [1 2 3]; % transfer function numerator>> den = [1 1/2 1/3]; % denominator coefficients>> [A,B,C,D] = tf2ss(num,den)A = 0B =10C = = 1>> [N,D] = ss2tf(A,B,C,D)N = = DocumentationThetf2ssandss2tffunctions are documented well as within Matlab itself ( ,help tf2ss).
10 Related Signal Processing Toolbox functions include tf2sos Convert digital filter transfer functionparameters to second-order sections form. sos2ss Convert second-order filter sections tostate- Space form. tf2zp Convert transfer function filter parametersto zero-pole-gain form. zp2ss Convert zero-pole-gain filter parameters tostate- Space TransformationsAsimilarity transformationof a State - Space system is alinear change of State variable coordinates:x(n) =E x(n)where x(n) =original State vector x(n) = State vector innew coordinates E=anyinvertible(one-to-one) matrix(linear transformation)Substitutingx(n) =E x(n)givesE x(n+ 1) =A E x(n) +Bu(n)y(n) =CE x(n) +Du(n)Premultiplying the first equation above byE 1gives x(n+ 1) = E 1AE x(n) + E 1B u(n)y(n) = (CE) x(n) +Du(n)Define thetransformed system matricesby A=E 1AE B=E 1B C=CE D=D26We can now write x(n+ 1) = A x(n) + Bu(n)y(n) = C x(n) +Du(n)The transformed system describes thesame systeminnew State -variable coordinatesLet s verify that the transfer function has not changed.