PRACTICAL MATLAB® FOR ENGINEERS PRACTICAL MATLAB

(sharon) #1

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)^2

IntVTSQ =
0.4050

>> ITSQ = (5*cos(200*pi*t+pi/3)).^2; % i(t)^2
>> IntITSQ = .01*T*(trapz(ITSQ)) % integral of i(t)^2

IntITSQ =
0.1250

>> VRMS = sqrt((IntVTSQ)/T) % RMS value of voltage

VRMS =
6.3640

>> IRMS = sqrt((IntITSQ)/T) % RMS value of current.

IRMS =
3.5355

>> % average power using trapz
>> PowerWave = .01*T*trapz(PT)/T

PowerWave =
21.7333

>> % Power Factor numerical
>> PF = PowerWave/(VRMS*IRMS)

PF =
0.9659

>> % verify results analytically
>> VRMSANA = 9*.707

VRMSANA =
6.3630

>> IRMSANA = 5*.707

IRMSANA =
3.5350
Free download pdf