## Contents

```% Skills Assessment - Chap 3
```

## P3.1 Simple pendulum

```clear variables
syms th om Om g l T real
syms s
%Pendulum equations in Laplace variable
eq1=s*th-om;
eq2=s*om+g/l*th-T;
[A,B]=equationsToMatrix([eq1,eq2],[th,om]);
disp('State transition matrix:')
A=subs(A,g/l,Om^2);
eAt=ilaplace(inv(A))
disp('Response modes:')
[Om;1].*eAt(:,2)
%ilaplace(1./diag(A))
```
```State transition matrix:
eAt =
[     cos(Om*t), sin(Om*t)/Om]
[ -Om*sin(Om*t),    cos(Om*t)]
Response modes:
ans =
sin(Om*t)
cos(Om*t)
```

## P3.2 DC motor

```%clear variables
syms V ia th om R L J b kt kb tau real
syms s
%Motor equations in Laplace variable
eq1=R*ia+kb*om-V;
eq2=(J*s+b)*om-kt*ia;
eq2=subs(eq2,ia,solve(eq1,ia));
eq3=s*th-om;
[A,B]=equationsToMatrix([eq2,eq3],[om,th]);
A=subs(A,b+kt*kb/R,J/tau);
E=sym(eye(2));E(1,1)=1/J;
A=E*A; B=E*B;
disp('State transition matrix:')
eAt=ilaplace(inv(A))
disp('Response modes:')
ilaplace(1./diag(A))
```
```State transition matrix:
eAt =
[           exp(-t/tau), 0]
[ tau - tau*exp(-t/tau), 1]
Response modes:
ans =
exp(-t/tau)
1
```

## P3.3 Dynamic system

```%clear variables
syms t real
G=zpk([-1],[0 -2 -5],1);
disp('Controller form:')
canon(G,'companion')
disp('Modal form:')
G=canon(G,'modal')
disp('Response modes:')
exp(diag(G.A)*t)
```
```Controller form:

ans =

a =
x1   x2   x3
x1    0    0    0
x2    1    0  -10
x3    0    1   -7

b =
u1
x1   1
x2   0
x3   0

c =
x1  x2  x3
y1   0   1  -6

d =
u1
y1   0

Continuous-time state-space model.

Modal form:

G =

a =
x1  x2  x3
x1   0   0   0
x2   0  -2   0
x3   0   0  -5

b =
u1
x1    0.8
x2  1.886
x3  1.521

c =
x1       x2       x3
y1    0.125  0.08839  -0.1754

d =
u1
y1   0

Continuous-time state-space model.

Response modes:
ans =
1
exp(-2*t)
exp(-5*t)
```

## P3.4 Dynamic system

```G=tf([1 1],[1 2 2 0]);
disp('Modal form:')
G=canon(G,'modal')
eAt=ilaplace(inv(s*eye(3)-G.a));
disp('Response modes:')
[eAt(1,1);eAt(2:3,3)]
%exp(eig(G.A)*t)
```
```Modal form:

G =

a =
x1  x2  x3
x1   0   0   0
x2   0  -1   1
x3   0  -1  -1

b =
u1
x1     0.5
x2   1.203
x3  0.7438

c =
x1       x2       x3
y1        1  -0.1148  -0.4864

d =
u1
y1   0

Continuous-time state-space model.

Response modes:
ans =
1
exp(-t)*sin(t)
exp(-t)*cos(t)
```

## P3.5 Automobile

```G=tf([28 120],[1 7 14]);
disp('Controller form:')
canon(G,'companion')
disp('Modal form:')
G=canon(G,'modal')
eAt=ilaplace(inv(s*eye(2)-G.a));
disp('Response modes:')
vpa(eAt(:,2),2)
%exp(eig(G.A)*t)
```
```Controller form:

ans =

a =
x1   x2
x1    0  -14
x2    1   -7

b =
u1
x1   1
x2   0

c =
x1   x2
y1   28  -76

d =
u1
y1   0

Continuous-time state-space model.

Modal form:

G =

a =
x1      x2
x1    -3.5   1.323
x2  -1.323    -3.5

b =
u1
x1   5.855
x2  0.9935

c =
x1      x2
y1   5.117  -1.972

d =
u1
y1   0

Continuous-time state-space model.

Response modes:
ans =
exp(-3.5*t)*sin(1.3*t)
exp(-3.5*t)*cos(1.3*t)
```

## P3.6 Human postural dynamics

```syms th om Om real
syms s
eq1=s*th-om;
eq2=s*om+Om^2*th-T;
[A,B]=equationsToMatrix([eq1,eq2],[th,om]);
disp('State transition matrix:')
A=subs(A,g/l,Om^2);
eAt=ilaplace(inv(A))
disp('Response modes:')
[Om;1].*eAt(:,2)
```
```State transition matrix:
eAt =
[     cos(Om*t), sin(Om*t)/Om]
[ -Om*sin(Om*t),    cos(Om*t)]
Response modes:
ans =
sin(Om*t)
cos(Om*t)
```