_ state space model tutorial
TRANSCRIPT
![Page 1: _ State Space Model Tutorial](https://reader031.vdocument.in/reader031/viewer/2022020306/5525ae05550346a26e8b4a21/html5/thumbnails/1.jpg)
The state space model represents a physical system as n first order coupled
differential equations. This form is better suited for computer simulation than an nth
order input-output differential equation.
The general vector-matrix form of the state space model is:
where y is the output equation, and x is the state vector
PARTS OF A STATE SPACE REPRESENTATION
State Variables: a subset of system variables which if known at an initial time toalong with subsequent inputs are determined for all time t>+t0
State Equations: n linearly independent first order differential equations relating thefirst derivatives of the state variables to functions of the state variables and theinputs.
Output equations: algebraic equations relating the state variables to the systemoutputs.
Note: The state variables are generally variables representing the state of energy
storage elements in a system.
The state space model can be found using the following steps:
Identify energy storage elementsDetermine energy relations for each elementPick off state variables from energy relationsFind trivial state equationsUse physics and algebra to find the other state equationsDefine a state vector (stack state variables in a vector)Take derivative of the state vector and relate this derivative to a vector-matrixmultiplication of the state vector and the inputs
IDENTIFY ENERGY STORAGE ELEMENTS AND SELECT STATES
In order to determine your state variables, you must identify energy storageelements. From the free body diagram, determine which energy storage elementsyour problem has. In many cases there can be multiple instances of eachelement.
Energy Storage Element Energy Relation State Variables
Spring ½ kx2 x
Inertia ½ mv2 v
In this example we will once again consider a sliding block where the... http://www.me.cmu.edu/ctms/modeling/tutorial/statespace/content.htm
Damper Does not store energy None
Applied Force Does not store energy None
EXAMPLE
Identify the energy storage elements and select the states of the tutorial problem:
From the example setup one can see that the setup consists of one instance eachof the applied force, a damper, a spring, and an inertia. Looking at the tableabove, our state vector must consist of the variables x and v.
IDENTIFYING TRIVIAL STATE EQUATIONS
Using definitions from mathematics, identify trivial state equations.
For example, by definition:
v = x'
Therefore the trivial state equation for the above system is x' = v whichexpresses the derivative of position in terms of states and inputs, in this case,just the velocity.
DETERMINING OTHER STATE EQUATIONS USING ELEMENT LAWS AND
INTERCONNECTIONS
In order to find the remaining state equations, we have to investigate otherrelations between the state variables based on element laws andinterconnections. The most commonly used of all interconnections is thegoverning equation from the free body diagram.
EXAMPLE
The equation gathered from the free body diagram was:
mx"+ bx' + kx - f(t) = 0
Substituting the definitions of the states into the equation results in:
mv' + bv + kx - f(t) = 0
In this example we will once again consider a sliding block where the... http://www.me.cmu.edu/ctms/modeling/tutorial/statespace/content.htm
![Page 2: _ State Space Model Tutorial](https://reader031.vdocument.in/reader031/viewer/2022020306/5525ae05550346a26e8b4a21/html5/thumbnails/2.jpg)
Solving for v' gives the state equation:
v' = (-b/m) v + (-k/m) x + f(t)/m
The desired output is for the position, x, so:
y = x
Now the derivatives of the state variables are in terms of the state variables,the inputs, and constants.
x' = v
v' = (-k/m) x + (-b/m) v + f(t)/m
y = x
PUTTING INTO VECTOR-MATRIX FORM
Now to put the equations above into the form:
where y is the output equation, and x is the state vector
EXAMPLE
Our state vector consists of two variables, x and v so our vector-matrix will be in theform:
The first row of A and the first row of B are the coefficients of the first stateequation for x'. Likewise the second row of A and the second row of B arethe coefficients of the second state equation for v'. C and D are thecoefficients of the output equation for y. This yields:
Therefore
In this example we will once again consider a sliding block where the... http://www.me.cmu.edu/ctms/modeling/tutorial/statespace/content.htm
HOW TO INPUT THE STATE SPACE MODEL INTO MATLAB
In order to enter a state space model into MATLAB, the variables much be givennumerical value, because MATLAB cannot manipulate symbolic variables withoutthe symbolic toolbox. Enter the coefficient matrices A, B, C, and D into MATLAB.The syntax for defining a state space model in MATLAB is:
statespace = ss(A, B, C, D)
where A, B, C, and D are from the standard vector-matrix form of a state spacemodel.
EXAMPLE
Input the tutorial state space model into MATLAB:
Theoretical values must be determined for the constants m, b, and k. For the sakeof example, we will take m = 2, b = 5, and k = 3.
>> m = 2;
>> b = 5;
>> k = 3;
>> A = [ 0 1 ; -k/m -b/m ];
>> B = [ 0 ; 1/m ];
>> C = [ 1 0 ];
>> D = 0;
>> tutorial_ss = ss(A, B, C, D)
This assigns the state space model under the name tutorial_ss and output thefollowing:
a =x1 x2
In this example we will once again consider a sliding block where the... http://www.me.cmu.edu/ctms/modeling/tutorial/statespace/content.htm
![Page 3: _ State Space Model Tutorial](https://reader031.vdocument.in/reader031/viewer/2022020306/5525ae05550346a26e8b4a21/html5/thumbnails/3.jpg)
x1 0 1x2 -1.5 -2.5
b =u1
x1 0x2 0.5
c =x1 x2
y1 1 0
d =u1
y1 0
Continuous-time model.
EXTRACTING A, B, C, D MATRICES FROM A STATE SPACE MODEL
In order to extract the A, B, C, and D matrices from a previously defined state spacemodel, use MATLAB's ssdata command.
[A, B, C, D] = ssdata(statespace)
where statespace is the name of the state space system.
EXAMPLE
Extract the A, B, C, and D matrices from tutorial_ss using MATLAB:
>> [A, B, C, D] = ssdata(tutorial_ss)
The MATLAB output will be:
A =
-2.5000 -0.37504.0000 0
B =
0.25000
C =
0 0.5000
In this example we will once again consider a sliding block where the... http://www.me.cmu.edu/ctms/modeling/tutorial/statespace/content.htm
D =
0
STEP RESPONSE USING THE STATE SPACE MODEL
Once the state space model is entered into MATLAB it is easy to calculate theresponse to a step input. To calculate the response to a unit step input, use:
step(statespace)
where statespace is the name of the state space system.
For steps with magnitude other than one, calculate the step response using:
step(u * statespace)
where u is the magnitude of the step and statespace is the name of the statespace system.
EXAMPLE
Find the unit step response and the step response when u = 4 of tutorial_ss using
MATLAB:
First to find the unit step response:
>> step(tutorial_ss)
The MATLAB output will be the following plot of the unit step response:
In this example we will once again consider a sliding block where the... http://www.me.cmu.edu/ctms/modeling/tutorial/statespace/content.htm
![Page 4: _ State Space Model Tutorial](https://reader031.vdocument.in/reader031/viewer/2022020306/5525ae05550346a26e8b4a21/html5/thumbnails/4.jpg)
To find the step response when u = 4:
>> u = 4;
>> step(u * tutorial_ss)
The MATLAB output will be the following plot of the step response:
In this example we will once again consider a sliding block where the... http://www.me.cmu.edu/ctms/modeling/tutorial/statespace/content.htm
IMPULSE RESPONSE USING THE STATE SPACE MODEL
MATLAB can also plot the impulse response of a state space model. The syntax forthe impulse response function in MATLAB is:
impulse(u * statespace)
where u is the magnitude of the impulse and statespace is the name of the statespace system.
EXAMPLE
Find the impulse response of tutorial_ss with an input of u = 2 using MATLAB:
>> u = 2;
>> impulse(u * tutorial_ss)
The MATLAB output will be the following plot of the impulse response:
BODE PLOT USING THE STATE SPACE MODEL
MATLAB’s bode command plots the frequency response of a system as a bodeplot. The syntax for the bode plot function in MATLAB is:
bode(statespace)
In this example we will once again consider a sliding block where the... http://www.me.cmu.edu/ctms/modeling/tutorial/statespace/content.htm
![Page 5: _ State Space Model Tutorial](https://reader031.vdocument.in/reader031/viewer/2022020306/5525ae05550346a26e8b4a21/html5/thumbnails/5.jpg)
where statespace is the name of the state space system.
EXAMPLE
Find bode plot of the frequency response of the system tutorial_ss using MATLAB:
>> bode(tutorial_ss)
The MATLAB output will be the following bode plot of the frequency response:
TRANSFER FUNCTION FROM STATE SPACE
MATLAB can determine the transfer function from the state space representation intwo ways. To find the numerator matrix and denominator vector of the transferfunction of the system from the matrices of the state space model use MATLAB'sss2tf command:
[num, den] = ss2tf(A, B, C, D)
where num is defined as the numerator matrix, and den is defined as thedenominator matrix, and A, B, C, and D are the coefficients of the state spacemodel.
In order to find the entire transfer function system from the state space model, usethe following command:
transferfunction = tf(statespace)
where statespace is the name of the state space system, andtransferfunction is the name of the generated transfer function system.
In this example we will once again consider a sliding block where the... http://www.me.cmu.edu/ctms/modeling/tutorial/statespace/content.htm
EXAMPLE
Find num and den, the numerator and denominator of the transfer function using A,
B, C, and D, the state space model coefficient matrices of tutorial_ss using
MATLAB:
>> [num, den] = ss2tf(A, B, C, D)
The MATLAB output will be:
num =
0 0 0.5000
den =
1.0000 2.5000 1.5000
Find the transfer function system of tutorial_ss using MATLAB:
>> tutorial_tf = tf(tutorial_ss)
MATLAB will assign the transfer function under the name tutorial_tf, andoutput the following:
Transfer function:0.5
-----------------s^2 + 2.5 s + 1.5
Carnegie Mellon University | University of Michigan
Mechanical Engineering Department
In this example we will once again consider a sliding block where the... http://www.me.cmu.edu/ctms/modeling/tutorial/statespace/content.htm