PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

Alternating Current Analysis 287


F = 1000;
W = 2*pi*F;
ZC = -j/(W*C);
ZT = R+ZC;
I = VS/ZT;
VR = R*I;
VC = ZC*I;
subplot(2,1,1)
% Phasors diagram.
VSS = [0 VS];
VVC = [0 VC];
VVR = [0 VR];
plot(real(VSS),imag(VSS),’*’,real(VVC),imag(VVC),’+’,real(VVR),imag(VVR),’o’);
xlabel(‘Real’), ylabel(‘Imaginary’),
title(‘Phasor Diagram (Example 3.12)’); % Figure 3.68 (top)
grid on
hold ; %hold plot
plot(r e a l(V S S), i m a g(V S S), r e a l(V V C),i m a g(V V C),r e a l(V V R),i m a g(V V R));
legend(‘VS’, ‘VC’, ‘VR’);
% Check the Phasor Diagram by applying Kirchhoffs Voltage Law.
disp(‘**********************************************************’)
disp(‘****Check the Phasor Diagram results by applying *****’)
disp(‘*********** Kirchhoffs Voltage Law *******************’)
Check _ Voltage = VR+VC
disp(‘**********************************************************’)
disp(‘ (Note:Check _ V should be equal to VS=1.)’)
T = 1/F;
t = [0:2*T/50:2*T]; % t for 2 periods
VS = sin(W.*t);
VRT = abs(VR)*sin(W.*t+angle(VR));
VCT = abs(VC)*sin(W.*t+angle(VC));
subplot (2,1,2)
p l o t (t,V S,’o’,t,V R T,’*’,t,V C T,’+’)
xlabel (‘time in seconds’),
ylabel (‘Amplitude in Volts’)
title(‘Voltages of the RC Circuit of Example 3.12’);
% Figure 3.68 (bottom)
grid on
lege nd(‘vs(t)’,’v r(t)’,’vc(t)’)

The MATLAB script fi le phasor_time_plots is executed, and the results are shown as
follows:

>> phasor _ time _ plots

Current plot held
*********************************************************
****Check the Phasor Diagram results by applying*****
************** Kirchhoffs Voltage Law ******************
Check _ Voltage =
1
*****************************************************

(note that the correct result is verified by Check _ Voltage=1)
Free download pdf