164 Practical MATLAB® Applications for Engineers
>> Vmax = v(40)
Vmax =
32.9680
>> for k=41:200
t(k)=k/20; % 2 < t < 10
v(k)=Vmax*exp(-(t(k)-t(40))/tau2);
t(40)=40/20=2sec=t1
i(k)= -v(k)/(R2+R3);
end
>> % plot the Voltage VC(t)
>> subplot(2,1,1)
>> plot(t,v)
>> axis([0 10 0 40]);
>> title (‘Transients in the circuit of Fig 2.62’)
>> xlabel(‘time in sec’), ylabel(‘Voltage vc(t)’)
>> grid on
>> % plot the current IC (t)
>> subplot(2,1,2)
>> plot(t,i)
>> axis([0 10 -13 15]);
>> xlabel(‘time in sec’),ylabel(‘Current ic(t)’)
>> grid onThe plots of the Voltage vc(t) and the Current ic(t) versus t are shown in Figure 2.63.FIGURE 2.63
Transient plots of Example 2.19.
403020100
01 2 34 5
time in sec6789100− 10− 50
Current ic(t)Voltage vc(t)5101512345
time in sec678910Transients in the circuit of Fig. 2.62