PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Direct Current and Transient Analysis 167


Req2 = R4+(R2*R3)/(R2+R3);
disp(‘* * * R E S U L T S * * * ‘)
disp(‘*****************************’)
disp(‘The network time constants are(in sec):’)
tau1 = L/Req1 % time constant #1
tau2 = L/Req2 % time constant #2
for K=1:40
t(K) = K/20; % 0 < t < 2.
I1(K) = (V/Req1)*(1-exp(-t(K)/tau1));
I2(K) = R3*I1(K)/(R2+R3);
I3(K) = R2*I1(K)/(R2+R3);
VL(K) = V-I1(K)*Req1;
end
disp(‘the maximum currents are:’)
I1Max = I1(40);
for K= 41:100
t(K) = K/20; % 2 < t < 5.
I1(K) = I1Max*exp(-(t(K)-t(40))/tau2); % t(40) = 40/20 = 2 sec.= t1
I2(K) = R3*I1(K)/(R2+R3);
I3(K) = R2*I1(K)/(R2+R3);
VL(K) = -I1(K)*Req2;
end
% plots the current i1(t)
I1Max= max(I1)
Tmax = max(t);
subplot(2,2,1)
plot(t,I1)
axis([0 5 0 10])
grid on
title(‘Current i1(t) vs.t’), ylabel(‘Current in amps’);
xlabel(‘time in sec’) % plots the current i2(t)
I2Max = max(I2)
I3Max=max(I3)
subplot(2,2,2)
plot(t,I2)
axis([0 5 0 6])
grid on
title(‘Current i2(t) vs.t’), ylabel(‘Current in amps’);
xlabel(‘time in sec’)
subplot(2,2,3) % plots the current i3(t)
plot(t,I3)
axis([0 5 0 3])
grid on
title(‘Current i3(t) vs. t’), ylabel(‘Current in amps’)
xlabel(‘time in seconds’); % plots the voltage vL(t)
disp(‘ The magnitude of the maximum voltage across L is:’)
VLMax = -max(abs(VL))
subplot(2,2,4)
plot(t,VL)
axis([0 5 -160 100])
grid on
title(‘Voltage vL(t) vs.t’), xlabel(‘time in seconds’)
ylabel(‘Voltage in volts ‘)
disp(‘***************************************’)
Free download pdf