## Contents

```% Skills Assessment - Chap 4
```

## P4.1 System model

```clear variables
G=zpk([],[0 -1 -2],1);
disp('Gain margin:')
Kstab=margin(G)
```
```Gain margin:
Kstab =
6.0000
```

## P4.2 System model

```disp('Characteristic polynomials:')
wn=1; zi=.8; a=[1 2*zi*wn wn^2] %step(tf(wn^2,a))
wn=1; zi=.69; a=[1 2*zi*wn wn^2] %step(tf(wn^2,a))
tr=.5; zi=.7; wn=3*zi/tr; a=[1 2*zi*wn wn^2] %step(tf(wn^2,a))
ts=2; zi=.69; wn=zi/(4.5*ts); a=[1 2*zi*wn wn^2] %step(tf(wn^2,a))
%wd=pi/log(tr); wn=wd/sqrt(1-zi^2); a=[1 2*zi*wn wn^2];
```
```Characteristic polynomials:
a =
1.0000    1.6000    1.0000
a =
1.0000    1.3800    1.0000
a =
1.0000    5.8800   17.6400
a =
1.0000    0.1058    0.0059
```

## P4.3 System models

```disp('Steady-state error:')
G=zpk([],[-1],1); estep=1/(1+dcgain(G));
disp('a.'), disp(['err_step', num2cell(estep)])
%
G=zpk([],[0 -1],1); estep=1/(1+dcgain(G)) ;
D=zpk(0,[],1);
eramp=1/dcgain(D*G);
disp('b.'), disp(['err_step', num2cell(estep)])
disp(['err_ramp', num2cell(eramp)])
%
G=zpk([],[-1 -2],1); estep=1/(1+dcgain(G));
disp('c.'), disp(['err_step', num2cell(estep)])
%
G=zpk([],[0 -2],1); estep=1/(1+dcgain(G)) ;
eramp=1/dcgain(D*G);
disp('d.'), disp(['err_step', num2cell(estep)])
disp(['err_ramp', num2cell(eramp)])
```
```Steady-state error:
a.
'err_step'    [0.5000]
b.
'err_step'    [0]
'err_ramp'    [1]
c.
'err_step'    [0.6667]
d.
'err_step'    [0]
'err_ramp'    [2]
```

## P4.4 Plant model

```syms k
G=zpk([],[0 -2 -25],25);
[num, den]=tfdata(G,'v');
disp('Characteristic polynomial:')
p=den+[0 0 0 k]
disp('Gain margin:')
Kstab=margin(G)
g=dcgain(G);
dg=dcgain(D*G);
estep=1/(1+k*g);
disp('step:'), disp(estep)
D=zpk(0,[],1);
eramp=1/(k*dg);
disp('ramp:'), disp(eramp)
edist=-g/(1+k*g);
disp('dist:'), disp(edist)
```
```Characteristic polynomial:
p =
[ 1, 27, 50, k]
Gain margin:
Kstab =
54.0000
step:
0
ramp:
2/k
dist:
NaN
```

## P4.5 Sensitivity

```syms s a K
G=K*(s+a)/s/(s+1);
STG=1/(1+G);
SGa=limit(G,s,0);
STa=STG*SGa;
%Alternatively
T=G/(1+G);
STa=a/T*diff(T,a);
disp('Sensitivity function: STa')
simplify(STa)
```
```Sensitivity function: STa
ans =
(a*s*(s + 1))/((a + s)*(s + K*a + K*s + s^2))
```

## P4.6 Human postural dynamics

```syms s m l I K
disp('Sensitivity analysis:')
G=K/(s^2-m*l/(I+m*l^2));
STG=1/(1+G);
SGl=diff(G,l);
SGI=diff(G,I);
SGm=diff(G,m);
disp('Sensitivity to changes in length:')
STl=simplify(STG*SGl)
disp('Sensitivity to changes in mass:')
STm=simplify(STG*SGm)
disp('Sensitivity to changes in MOI:')
STI=simplify(STG*SGI)
```
```Sensitivity analysis:
Sensitivity to changes in length:
STl =
(K*m*(- m*l^2 + I))/((m*l^2*s^2 - m*l + I*s^2)*(m*l^2*s^2 + K*m*l^2 - m*l + I*s^2 + I*K))
Sensitivity to changes in mass:
STm =
(I*K*l)/((m*l^2*s^2 - m*l + I*s^2)*(m*l^2*s^2 + K*m*l^2 - m*l + I*s^2 + I*K))
Sensitivity to changes in MOI:
STI =
-(K*l*m)/((m*l^2*s^2 - m*l + I*s^2)*(m*l^2*s^2 + K*m*l^2 - m*l + I*s^2 + I*K))
```