Contents

```% Skills Assessment - Chap 7
```

P7.1 DC motor

```clear variables
G=zpk([],[0 -10],1);
Ts=.01;
Gz=c2d(G,Ts);
disp('Gain margin:')
Kmax=margin(Gz)
disp('Impulse response:')
impulse(Gz,10*Ts)'
```
```Gain margin:
Kmax =
2.0339e+03
Impulse response:
ans =
Columns 1 through 7
0    0.0048    0.0139    0.0221    0.0295    0.0362    0.0423
Columns 8 through 11
0.0478    0.0527    0.0572    0.0613
```

P7.2 Flexible beam

```G=tf(100,[1 1 100]);
Ts=.01;
Gz=c2d(G,Ts);
disp('Gain margin:')
Kmax=margin(Gz)
disp('Impulse response:')
impulse(Gz,10*Ts)'
```
```Gain margin:
Kmax =
2.0058
Impulse response:
ans =
Columns 1 through 7
0    0.4979    1.4822    2.4420    3.3679    4.2511    5.0833
Columns 8 through 11
5.8567    6.5641    7.1992    7.7565
```

P7.3 Transfer function

```G=zpk([-3],[0 -1 -2],1);
Ts=.1;
Gz=c2d(G,Ts);
disp('Gain margin:')
Kmax=margin(Gz)
disp('Impulse response:')
impulse(Gz,10*Ts)'
```
```Gain margin:
Kmax =
7.1207
Impulse response:
ans =
Columns 1 through 7
0    0.0499    0.1489    0.2455    0.3387    0.4278    0.5123
Columns 8 through 11
0.5920    0.6666    0.7363    0.8011
```

P7.4 Automobile model

```G=tf([28 120],[1 7 14]);
Ts=.1;
Gz=c2d(G,Ts);
disp('Gain margin:')
Kmax=margin(Gz)
disp('Impulse response:')
impulse(Gz,10*Ts)'
```
```Gain margin:
Warning: The closed-loop system is unstable.
Kmax =
0.7173
Impulse response:
ans =
Columns 1 through 7
0   24.4349   18.2327   13.3382    9.5802    6.7606    4.6876
Columns 8 through 11
3.1916    2.1311    1.3924    0.8870
```

P7.5 Automobile model

```for k=0.5*Kmax
disp('K='), disp(k)
T=feedback(k*G,1);
disp('Pulse transfer function:')
Tz=feedback(k*Gz,1)
kp=k*dcgain(Gz);
estep=1/(1+kp)
disp('Step response:')
step(Tz, T)
legend('discrete','continuous')
end
```
```K=
0.3587
Pulse transfer function:

Tz =

0.8764 z - 0.5704
------------------------
z^2 - 0.5207 z - 0.07385

Sample time: 0.1 seconds
Discrete-time transfer function.

estep =
0.2454
Step response:
```

P7.6 Human postural dynamics

```G=tf([10],[1 0 -10]);
Ts=.1;
disp('Pulse transfer function:')
Gz=c2d(G,Ts)
disp('Impulse response:')
impulse(Gz,10*Ts)'
```
```Pulse transfer function:

Gz =

0.05042 z + 0.05042
-------------------
z^2 - 2.101 z + 1

Sample time: 0.1 seconds
Discrete-time transfer function.

Impulse response:
ans =
Columns 1 through 7
0    0.5042    1.5634    2.7802    4.2774    6.2059    8.7602
Columns 8 through 11
12.1979   16.8655   23.2338   31.9449
```