190 Practical MATLAB® Applications for Engineers
Note that the symbolic results shown in Figure 2.90 fully agree with the numerical
results shown in Figure 2.91.
Example 2.27
Steady-state conditions exist in the network shown in Figure 2.92 at t = 0 −, when the
V 1 = 10 V source is connected to the RC circuit. At t = 0 +, the switch moves downward,
and the V 2 = 20 V source is connected to the RC circuit (while the source V 1 = 10 V is
disconnected), for t ≥ 0.
- Write and solve the loop differential equation by hand, for the current i(t) (through
RC) and the voltages vR(t) and vC(t), for t ≥ 0. - Create the script fi le RC_ IC that returns the solutions for part 1 using the MATLAB
symbolic solver dsolve. - Repeat part 1 by using the MATLAB numerical solver ode45.
- Also, obtain the plots of
a. i(t) versus t
b. vR(t) versus t
c. vc(t) versus t
over the range 0 ≤ t ≤ 2 s, for parts 2 and 3.
FIGURE 2.91
Plots of numerical transient solutions of Example 2.26.
1.61.41.210.80.60.40.20 21.8
6
4
8
10
plots of [i(t), vr(t), and vL(t)] versus t
i(t) in amps
vr(t) in volts
vL(t) in volts
1.61.41.210.80.60.40.20 21.8
10
15
10
1.61.41.210.8 21.8
time in sec
0.60.40.20
0
5
10