## Contents

```% Skills Assessment - Chap 9
```

## P9.1 Inverted pendulum

```disp('Inverted pendulum')
clear variables
g=9.8;
A=[0 1; g 0]; B=[0; 1];
disp('State feedback controller:')
K=place(A,B,roots([1 5*sqrt(2) 25]))
```
```Inverted pendulum
State feedback controller:
K =
34.8000    7.0711
```

## P9.2 DC motor

```disp('DC motor')
R=1; L=.01; J=.01; b=.1; k=.02;
A=[L 0;0 J]\[-R -k; k -b];
B=[L 0;0 J]\[1; 0];
r=[-200+j*100 -200-j*100];
disp('State feedback controller:')
K=place(A,B,r)
```
```DC motor
State feedback controller:
K =
2.9000  230.4800
```

## P9.3 Airplane dynamics

```disp('Airplane dynamics')
disp('State feedback controller:')
A=[-1 1; -7 -.5]; B=[-.1; -5];
r=5*[-1+j -1-j];
K=place(A,B,r)
disp('Tracking PI controller:')
C=[1 0];
A1=[A 0*B; -C 0]; B1=[B; 0];
r1=[r -5*sqrt(2)];
K1=place(A1,B1,r1)
AP=ss(A1-B1*K1,[0;0;1],[C 0],0);
disp('Step response:')
step(AP) %error
```
```Airplane dynamics
State feedback controller:
K =
-7.0890   -1.5582
Tracking PI controller:
K1 =
-18.6983   -2.7402   70.0106
Step response:
```

## P9.4 Inverted pendulum over cart

```disp('Inverted pendulum over cart:')
disp('State feedback controller:')
A=[0 0 1 0; 0 0 0 1; [11 1;1 1]\[0 0;0 1]*g [0 0; 0 0]];
B=[0;0;[11 1;1 1]\[1; 0]];
r=[-5+j -5-j -6+j -6-j];
K=place(A,B,r)
```
```Inverted pendulum over cart:
State feedback controller:
K =
1.0e+03 *
-0.9816   -2.9194   -0.6959   -0.9159
```

## P9.5 Flexible beam

```disp('Tracking PI controller:')
wn=1e2; zi=.05;
A=[0 1; -wn^2 -2*zi*wn]; B=[0; wn]; C=[wn 0];
A1=[A 0*B; -C 0]; B1=[B; 0];
r=[100*[-2+j -2-j] -100*sqrt(5)];
K=place(A1,B1,r)
FB=ss(A1-B1*K,[0;0;1],[C 0],0);
disp('Step response:')
step(FB)
```
```Tracking PI controller:
K =
1.0e+03 *
1.2944    0.0061   -1.1180
Step response:
```

## P6.6 Human postural dynamics

```G=tf([10],[1 0 -10]);
G=ss(G);
('State feedback controller:')
[A,B,C]=ssdata(G);
r=[-5+j -5-j];
K=place(A,B,r)
('Tracking PI controller:')
A1=[A 0*B; -C 0]; B1=[B; 0];
r=[r -sqrt(26)];
K=place(A1,B1,r)
HB=ss(A1-B1*K,[0;0;1],[C 0],0);
disp('Step response:')
step(HB)
```
```ans =
State feedback controller:
K =
5.0000    4.5000
ans =
Tracking PI controller:
K =
7.5495   10.8738  -13.2575
Step response:
```