## Contents

```% Skills Assessment - Chap 2
```

## P2.1 Series RLC circuit

```clear variables
syms I V Vs R L C w real
syms s
%Circuit equations in Laplace variable
eq1=(L*s+R)*I+V-Vs;
eq2=C*s*V-I;
[A,B]=equationsToMatrix([eq1,eq2],[I,V]);
A1=subs(A,[R,L,C],[2,1,.1]);
B1=subs(B,Vs,1);
disp('Transfer functions:')
H=linsolve(A1,B1)
disp('Impulse response:')
ilaplace(H(2));
rewrite(ans,'exp'); expand(ans); collect(ans); simplify(ans);
vpa(ans,2)
disp('Step response:')
ilaplace(H(2)/s);
rewrite(ans,'exp'); expand(ans); collect(ans); simplify(ans);
vpa(ans,2)
disp('Frequency response:')
subs(H,s,j*w)
```
```Transfer functions:
H =
s/(s^2 + 2*s + 10)
10/(s^2 + 2*s + 10)
Impulse response:
ans =
- exp(t*(- 1.0 + 3.0i))*1.7i + exp(t*(- 1.0 - 3.0i))*1.7i
Step response:
ans =
1.0 - exp(t*(- 1.0 - 3.0i))*(0.5 + 0.17i) - exp(t*(- 1.0 + 3.0i))*(0.5 - 0.17i)
Frequency response:
ans =
(w*1i)/(- w^2 + w*2i + 10)
10/(- w^2 + w*2i + 10)
```

## P2.2 Parallel RLC circuit

```clear variables
syms I V Is R L C w real
syms s
%Circuit equations in Laplace variable
eq1=(C*s+1/R)*V+I-Is;
eq2=L*s*I-V;
[A,B]=equationsToMatrix([eq1,eq2],[I,V]);
A1=subs(A,[R,L,C],[2,1,.1]);
B1=subs(B,Is,1);
disp('Transfer functions:')
H=linsolve(A1,B1)
disp('Impulse response:')
ilaplace(H(2));
rewrite(ans,'exp'); expand(ans); collect(ans); simplify(ans);
vpa(ans,2)
disp('Step response:')
ilaplace(H(2)/s);
rewrite(ans,'exp'); expand(ans); collect(ans); simplify(ans);
vpa(ans,2)
disp('Frequency response:')
subs(H,s,j*w)
```
```Transfer functions:
H =
10/(s^2 + 5*s + 10)
(10*s)/(s^2 + 5*s + 10)
Impulse response:
ans =
exp(t*(- 2.5 + 1.9i))*(5.0 + 6.5i) + exp(t*(- 2.5 - 1.9i))*(5.0 - 6.5i)
Step response:
ans =
- exp(t*(- 2.5 + 1.9i))*2.6i + exp(t*(- 2.5 - 1.9i))*2.6i
Frequency response:
ans =
10/(- w^2 + w*5i + 10)
(w*10i)/(- w^2 + w*5i + 10)
```

## P2.3 DC motor

```clear variables
syms V ia th om R L J b kt kb w real
syms s
%Motor equations in Laplace variable
eq1=(L*s+R)*ia+kb*om-V;
eq2=(J*s+b)*om-kt*ia;
%eq3=s*th-om;
[A,B]=equationsToMatrix([eq1,eq2],[ia,om]);
A1=subs(A,[L,R,J,b,kt,kb],[.01,1,.01,.1,.02,.02]);
B1=subs(B,V,1);
disp('Transfer functions:')
H=linsolve(A1,B1)
disp('Impulse response:')
ilaplace(H(2));
rewrite(ans,'exp'); expand(ans); collect(ans); simplify(ans);
vpa(ans,2)
disp('Step response:')
ilaplace(H(2)/s);
rewrite(ans,'exp'); expand(ans); collect(ans); simplify(ans);
vpa(ans,2)
disp('Frequency response:')
subs(H,s,j*w)
```
```Transfer functions:
H =
(100*(s + 10))/(s^2 + 110*s + 1004)
200/(s^2 + 110*s + 1004)
Impulse response:
ans =
-2.2*exp(-111.0*t)*(1.0*exp(10.0*t) - exp(100.0*t))
Step response:
ans =
0.022*exp(-100.0*t) - 0.22*exp(-10.0*t) + 0.2
Frequency response:
ans =
(100*(10 + w*1i))/(- w^2 + w*110i + 1004)
200/(- w^2 + w*110i + 1004)
```

## P2.4 DC Motor - simplified

```disp('Transfer functions:')
A1=subs(A,[L,R,J,b,kt,kb],[0,1,.01,.1,.02,.02]);
H=linsolve(A1,B1)
disp('Impulse response:')
ilaplace(H(2));
vpa(ans,2)
disp('Step response:')
ilaplace(H(2)/s);
vpa(ans,2)
disp('Frequency response:')
subs(H,s,j*w)
```
```Transfer functions:
H =
(25*(s + 10))/(25*s + 251)
50/(25*s + 251)
Impulse response:
ans =
2.0*exp(-10.0*t)
Step response:
ans =
0.2 - 0.2*exp(-10.0*t)
Frequency response:
ans =
(25*(10 + w*1i))/(251 + w*25i)
50/(251 + w*25i)
```

## P2.5 Spring-Mass-Damper

```clear variables
syms x dx m b k f w real
syms s
%Dynamic equations in Laplace variable
eq1=(m*s^2+b*s+k)*x-f;
eq2=s*x-dx;
[A,B]=equationsToMatrix([eq1,eq2],[x,dx]);
A1=subs(A,[m,b,k],[1,2,2]);
B1=subs(B,f,1);
disp('Transfer functions:')
H=linsolve(A1,B1)
disp('Impulse response:')
ilaplace(H(1));
vpa(ans,2)
disp('Step response:')
ilaplace(H(1)/s);
vpa(ans,2)
disp('Frequency response:')
subs(H,s,j*w)
```
```Transfer functions:
H =
1/(s^2 + 2*s + 2)
s/(s^2 + 2*s + 2)
Impulse response:
ans =
exp(-1.0*t)*sin(t)
Step response:
ans =
0.5 - 0.5*exp(-1.0*t)*(cos(t) + sin(t))
Frequency response:
ans =
1/(- w^2 + w*2i + 2)
(w*1i)/(- w^2 + w*2i + 2)
```