# E12 Assignment 09

Description:

Problems:
1. Eye model in state space

Consider the model of the eye shown below (we will consider rotations in the horizontal plane only).  The elements K3 and B3 represent the restoring forces of tendons and other structures attached to the eye (these are rotational elements, the torque they generate is proportional to angular position and velocity). The eye's moment of inertia is J (all other elements are massless).  To the left and the right of the eye are two muscles, the medial rectus (moves the eye toward the body's centerline) and the lateral rectus (moves the eye away from the centerline).  The muscles (and associated connective tissue) are modeled by a parallel force generator and friction, which are in series with a spring -- these elements are translational.  Rotational elements are in capital letters, and blue; translational elements are in lowercase and green.

Develop a state space model with two inputs (f1 and f2) and one output (θ).  Choose as state variables, x1, x2, θ and ω.  The equations of motion are given by:

Solution:

2. State space model of RLC circuit

Consider the circuit shown below:

a) Derive a state space model using energy storage variables (i.e., inductor currents and capacitor voltages) as the state variables.

b) Use impedances to derive the transfer function H(s)=Eout(s)/Ein(s).

c) Use the transfer function to derive a second state space model.

Solution:

a)

b)

c) One possible result is given below.  Other answers are possible.

3. State space model of building, no input derivatives

The diagram below shows a simple model of a building.  Each floor has a mass, and the walls connecting the floors are modeled as a spring and dashpot.  The bottom of the building may move (due to an earthquake, for example) - the position xin is the input to the system..

a) Draw free body diagrams of the building and write equations of motion

b) Assume you have access to both xin(t) and vin(t) (v is velocity, i.e., derivative of the input).   Develop a state space model with two inputs xin and vin, and three outputs: x1, x2, and x3.  Choose as state variables the position and velocities of the floors.

Solution:

a)

b)

4. Xfer function to State Space, 3rd order, CCF

Find the controllable canonic form of a system described by the transfer function (CCF form is described here)

Solution:

Check with MATLAB

```>> sys=ss([0 1 0; 0 0 1; -1 -1 -2],[0 0 1]',[-2 -2 -6],3);

>> [n,d]=tfdata(sys,'v')
n =
3.0000   -0.0000    1.0000    1.0000
d =
1.0000    2.0000    1.0000    1.0000```
5. State Space to Xfer Func - 2 systems

a) Find the transfer function of the system defined by:

Recall that the inverse of a 2x2 matrix is given by:

b) Find the transfer function of the system defined by:

Solution:

a)

```>> syms s
>> A=[-5 -2; 2 0];  B=[2 1]';  C=[3 2];  D=0;

>> s*eye(2)-A
ans =
[ s + 5, 2]
[    -2, s]

>> Phi=inv(ans)
Phi =
[ s/(s^2 + 5*s + 4),      -2/(s^2 + 5*s + 4)]
[ 2/(s^2 + 5*s + 4), (s + 5)/(s^2 + 5*s + 4)]

>> H=simple(C*Phi*B+D)
H =
(8*s + 12)/(s^2 + 5*s + 4)```

b)

```>> A=[0 2; -2 -5];  B=[1 2]';  C=[2 3];  D=0;
>> H=simple(C*inv(s*eye(2)-A)*B+D)
H =
(8*s + 12)/(s^2 + 5*s + 4)```

Note: Systems are the same, but state variables are switched.

6. Zero input State Space 2x2

Given a system with the state space model

a) Find the state transition matrix in the Laplace domain, Φ(s).

b) Find the state transition matrix in the time domain, φ(t).

c) Find an expression for the output if the input is zero and the initial conditions are  and plot it for 7 seconds.

d) For the initial conditions given previously, plot y(t) using Matlab (and the "initial" command).

e) Plot the impulse response of the system using Matlab (and the "impulse" command).

Recall that the inverse of a 2x2 matrix is given by:

Solution:

a)

```>> syms s
>> A=[-5 -2; 2 0;]; B=[2 0]'; C=[1 3/4]; D=0;
>> Phi=simple(inv(s*eye(2)-A));
>> pretty(Phi)

+-                              -+
|       s               2        |
|  ------------, - ------------  |
|   2               2            |
|  s  + 5 s + 4    s  + 5 s + 4  |
|                                |
|       2            s + 5       |
|  ------------,  ------------   |
|   2              2             |
|  s  + 5 s + 4   s  + 5 s + 4   |
+-                              -+```

b)

```>> phi=simple(ilaplace(Phi));
>> pretty(phi)

+-                                              -+
|      4           1          2           2      |
|  ---------- - --------, ---------- - --------  |
|  3 exp(4 t)   3 exp(t)  3 exp(4 t)   3 exp(t)  |
|                                                |
|     2           2          4           1       |
|  -------- - ----------, -------- - ----------  |
|  3 exp(t)   3 exp(4 t)  3 exp(t)   3 exp(4 t)  |
+-                                              -+```

or

c)

```>> q0=[1 -1]';
>> q=simple(phi*q0);
>> pretty(q)
+-                  -+
|    exp(3 t) + 2    |
|    ------------    |
|     3 exp(4 t)     |
|                    |
|    2 exp(3 t) + 1  |
|  - --------------  |
|      3 exp(4 t)    |
+-                  -+```

or

```>> y=simple(C*q);
>> pretty(y)
5           1
----------- - --------
12 exp(4 t)   6 exp(t)```

or

```>> t=linspace(0,4,1000);
>> plot(t,eval(y));
>> title('Output of zero input problem'); ylabel('y(t)');  xlabel('t');```

d)

```>> sys=ss(A,B,C,D);
>> initial(sys,q0);```

e)       >> impulse(sys)

7. Body with wobbling masses

The system shown below is from an article entitled "Effects of Muscle Fatigue on the Ground Reaction Force and Soft-Tissue Vibrations During Running: A Model Study," by Nikooyan and Zadpoor in IEEE Transactions on Biomedical Engineering, Vol  59, No. 3, page 797, March 2012.  The model is that of the human body as it comes in contact with the ground.  The paper examines fatigue as indicated by the amount of shaking of m2 and m4.

The paper describes the model as follows "Two of these masses represent the upper body rigid (m3) and wobbling (m4) masses, and the other two represent the lower body rigid (m1) and wobbling (m2) masses.  The springs and dampers represent the stiffness and damping properties of the human body hard and soft tissues."  As the foot hits the ground, there is an opposing force determined by the "ground reaction model" that depends in a complex way on the kind of turf and the kind of shoes being worn, and is too complex to consider here.

We will simplify the model by assuming that m1 is in direct contact with the ground (so x1(t)=0).   The simplified model is redrawn below.

a) Derive equations of motion.

b) Derive a state space model with three outputs, x2, x3 and x4.  Note there is no input, so you don't need a B or D matrix.

c) The paper gives model values as m1=6.15 kg, m2=6 kg, m3=12.6 kg, m4=50.3 kg, k1=k2=6000 N/m, k3=k4=10000 N/m, k5=18000 N/m, b1=300 kg/s, b2=650 kg/s and b4=1900 kg/s.   Examine the roots of the characteristic equation (Matlab's "damp" and "pzmap" can be used) and state whether or not you think the system will exhibit oscillatory behavior.

d) During a run, just as the foot strikes the ground, initial conditions are given in the paper for the velocities v2(0)=0.96 m/s, and v3(0)=v4(0)=2.0 m/s.  Assume initial positions are all zero.  Plot x2(t), x3(t) and x4(t).  Matlab's "initial" command may be used.

Solution:

a) the two spring attached to mass 4 act as one larger spring so let k4+k5=k45=28000 N/m.

b)

c)  Some of the roots of the characteristic equation are complex, so we expect some oscillation (ζ=0.33).

```%% Matlab commands
% Define constants
m2=6; m3=12.6; m4=50.3;
k1=6000; k2=6000; k3=10000; k45=28000;
b1=300; b2=650; b4=1900;

% Define state matrices
A = [[0 1 0  0 0 0];
[-k2-k3 -b2 k3  0 0 0]/m2;
[0 0 0  1 0 0];
[k3 0 -k1-k3-k45 -b1-b4 k45 b4]/m3;
[0 0 0  0 0 1];
[0 0 k45  b4 -k45 -b4]/m4];
B=[0 0 0 0 0 0]';
C=[1 0 0 0 0 0;
0 0 1 0 0 0;
0 0 0 0 1 0];
D=0;

sys=ss(A,B,C,D);
damp(sys)```
``` %% Matlab output

-3.91e+000 + 1.11e+001i     3.32e-001      1.18e+001
-3.91e+000 - 1.11e+001i     3.32e-001      1.18e+001
-1.52e+001                  1.00e+000      1.52e+001
-4.39e+001                  1.00e+000      4.39e+001
-6.57e+001                  1.00e+000      6.57e+001
-1.88e+002                  1.00e+000      1.88e+002  ```

d)

```q0=[0 0.96 0 2.0 0 2.0]';
initial(sys,q0)```

8. State Space to State Space - Difference mode, common mode

Consider a state space system given by:

For systems with two variables it is often convenient to know the system response as a represented by the difference between the variables and the average of the variables (called "difference mode" and "common mode," respectively).

a) Find the transformation matrices P and T such that:

b) Find the matrices in the new state variable equations

Recall that the inverse of a 2x2 matrix is given by:

Solution:

a)

b)

Check with Matlab

```>> A=[-5 -3; 2 0;];  B=[1 0]';  C=[1 0.5];  D=0;
>> sys=ss(A,B,C,D);
>> T=[1 -1; 0.5 0.5];
>> sysnew=ss2ss(sys,T)
a =
x1   x2
x1   -2  -10
x2    0   -3
b =
u1
x1    1
x2  0.5
c =
x1    x2
y1  0.25   1.5
d =
u1
y1   0```