Alternating Current Analysis 283
MATLAB Solution
>> % Instantaneous power plot
>> T= 2*pi/(200*pi);
>> X= [0:.01:1];
>> t = X.*T;
>> IT = 5*cos(200*pi*t+pi/3);
>> VT = 9*cos(200*pi*t+pi/4);
>> PT = IT.*VT;
>> plot(t,PT,’o’,t,VT,’*’,t,IT,’+’); % Figure 3.64
>> legend(‘i(t)’, ‘v(t)’, ‘p(t)’)
>> grid on
>> title(‘Instantaneous Power, Current, and Voltage’)
>> xlabel(‘time in seconds’),ylabel(‘ Amplitudes of P, I, &V’)
>> VTSQ=VT.^2; % v(t)^2
>> IntVTSQ = .01*T*(trapz(VTSQ)) % integral ofv(t)^2IntVTSQ =
0.4050>> ITSQ = (5*cos(200*pi*t+pi/3)).^2; % i(t)^2
>> IntITSQ = .01*T*(trapz(ITSQ)) % integral of i(t)^2IntITSQ =
0.1250>> VRMS = sqrt((IntVTSQ)/T) % RMS value of voltageVRMS =
6.3640>> IRMS = sqrt((IntITSQ)/T) % RMS value of current.IRMS =
3.5355>> % average power using trapz
>> PowerWave = .01*T*trapz(PT)/TPowerWave =
21.7333>> % Power Factor numerical
>> PF = PowerWave/(VRMS*IRMS)PF =
0.9659>> % verify results analytically
>> VRMSANA = 9*.707VRMSANA =
6.3630>> IRMSANA = 5*.707IRMSANA =
3.5350