PS2 Lab Manual
PS2 Lab Manual
>> a = 2
a =
2
>> x = [1;2;3]
x =
1
2
3
» x = [1 2 3 4 5]
x =
1 2 3 4 5
» y = [6;7;8;9;10]
y =
6
7
8
9
10
» y = [6,7,8,9,10]
y =
6 7 8 9 10
» y'
ans =
6
7
8
9
10
» u = [0:8]
u =
0 1 2 3 4 5 6 7 8
» v = [0:2:8]
Page 1
v =
0 2 4 6 8
» v(1:3)
ans =
0 2 4
» v(1:2:4)
ans =
0 4
» sin(pi/2)
ans =
1
» cos(pi/2)
ans =
6.1230e-017
» x = [0:0.1:1]
x =
Columns 1 through 7
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000
Columns 8 through 11
0.7000 0.8000 0.9000 1.0000
» y = exp(x)
y =
Columns 1 through 7
1.0000 1.1052 1.3499 1.4918 1.6487 1.8221
1.2214
Columns 8 through 2.7183
11
2.0138 2.2255
2.4596
» A = [9,7,0;0,8,6;7,1,-6]
A =
9 7 0
0 8 6
7 1 -6
» size(A)
ans =
3 3
» det(A)
ans =
-192
» inv(A)
Page 2
ans =
0.2812 -0.2187 -0.2187
-0.2187 0.2812 0.2812
0.2917 -0.2083 -0.3750
» A*inv(A)
ans =
1.0000 0.0000 0.0000
0.0000 1.0000 0.0000
0.0000 0.0000 1.0000
»
inv(A)*A
ans = 0
1.0000 0.0000
0.0000 1.0000 0
0.0000 0 1.0000
» eig(A)
ans =
12.6462
3.1594
-4.8055
» x=-pi:0.01:pi;
» y=cos(x);
» plot(x,y)
Page 3
» xlabel('x')
» ylabel('y=cos(x)')
Various line types, plot symbols and colors can be used. If these are not specified (as in the case above)
MATLAB will assign (and cycle through) the default ones as given in the table below.
y yellow . point
m magenta o circle
c cyan x x-mark
r red + plus
g green - solid
b blue * star
w white : dotted
k black -. dashdot
-- dashed
where the third argument indicating the color, appears within single quotes. We could get a dashed line instead
of a solid one by typing
» plot(x,y,’--’)
or even a combination of line type and color, say a blue dotted line by typing
» plot(x,y,’b:’)
Multiple curves can appear on the same graph. If for example we define another vector
» z = sin(x);
we can get both graphs on the same axis, distinguished by their line type, using
Page 4
» plot(x,y,'r--',x,z,'b:')
The resulting graph can be seen below, with the red dashed line representing y = cos(x) and the
blue dotted line representing z = sin(x).
When multiple curves appear on the same axis, it is a good idea to create a legend to label and distinguish them.
The command legend does exactly this.
» legend('cos(x)','sin(x)')
The text that appears within single quotes as input to this command, represents the legend labels. We must be
consistent with the ordering of the two curves, so since in the plot command we asked for cosine to be
plotted before sine, we must do the same here.
Page 5
At any point during a MATLAB session, you can obtain a hard copy of the current plot by either issuing the
command print at the MATLAB prompt, or by using the command menus on the plot window. In addition,
MATLAB plots can by copied and pasted (as pictures) in your favorite word processor (such as Microsoft
Word). This can be achieved using the Edit menu on the figure window.
Page 6
Date:
Experiment No. 2
Page 7
MATLAB Program:
Page 8
Plot:
Page 9
Date:
Experiment No. 3
Page 10
Page 11
MATLAB Program
VRLL=220; VR = VRLL/sqrt(3);
Z = (0.15+j*2*pi*60*1.3263e-3)*40;
disp('(a)')
SR=304.8+j*228.6;
IR = conj(SR)/(3*conj(VR)); IS = IR;
Page 12
VS = VR + Z*IR;
VSLL =
sqrt(3)*abs(VS) SS =
3*VS*conj(IS)
REG = (VSLL - VRLL)/VRLL*100
Eff =
real(SR)/real(SS)*100
disp('(b)')
SR=304.8-j*228.6;
IR = conj(SR)/(3*conj(VR)); IS =
IR; VS = VR + Z*IR;
VSLL =
sqrt(3)*abs(VS) SS =
3*VS*conj(IS)
REG = (VSLL - VRLL)/VRLL*100
Result
(a)
VSLL
250.0186
SS =
3.2280e+02 +
2.8858e+02i REG =
13.6448
Eff =
94.4252
(b)
VSLL
210.2884
SS =
3.2280e+02 -
1.6862e+02i REG =
-4.4144
Page 13
Eff =
94.4252
Page 14
Date:
Experiment No. 4
Page 15
MATLAB Program
Page 16
model =-1;
z = r + j*2*pi*f*L/1000; ; Z = z*Length;
R = real(Z); X = imag(Z);
y = g +
j*2*pi*f*C/1000000; Y =
y*Length;
if g== 0 & C==0
fprintf ('\n'), disp(' Short line
model') disp(' ')
fprintf('\n')
fprintf(' Z = %g + j ',real(Z)), fprintf('%g
ohms\n',imag(Z)),
Y = 0 + j*0; Zc = 0;
else
Zc = sqrt(Z/Y); Gamal=sqrt(Z*Y);
while model ~=1 & model~=2
model = input('Enter 1 for Medium line or 2 for long line --> ');
if model ~=1 & model~=2
disp(' Enter 1 or 2'), else, end
end
if model==2
Z = Zc*sinh(Gamal); Y = 2*tanh(Gamal/2) /Zc;
else, end
Page 17
end
if model == -1 | model ==1 |model ==2
% A,B,C,D constants of line
A = 1 + Z*Y/2; B = Z;
C = Y*(1 + Z*Y/4); D =
A; ABCD = [A B; C D];
disp(' ')
fprintf(' %-11.5g + j', real(A)), fprintf(' %-
11.5g', imag(A))
fprintf(' %-11.5g + j', real(B)), fprintf(' %-11.5g \n',
imag(B))
fprintf(' ABCD =
\n')
fprintf(' %-11.5g + j', real(C)), fprintf(' %-
11.5g', imag(C))
fprintf(' %-11.5g + j', real(D)), fprintf(' %-11.5g \n',
imag(D))
fprintf(' \n')
else, fprintf(' You must enter 1 or 2. Try again \n'), return, end
r = .036; g = 0; f = 60;
L = 0.8; % milli-Henry
C = 0.0112; % micro-Farad
Length = 130; VR3ph = 325;
VR = VR3ph/sqrt(3) + j*0; % kV (receiving end phase voltage)
[Z, Y, ABCD] = rlc2abcd(r, L, C, g, f, Length);
AR = acos(0.8);
SR = 270*(cos(AR) + j*sin(AR)); % MVA (receiving end power)
IR = conj(SR)/(3*conj(VR)); % kA (receiving end current)
VsIs = ABCD* [VR; IR]; % column vector [Vs; Is]
Vs = VsIs(1);
Vs3ph = sqrt(3)*abs(Vs); % kV(sending end L-L voltage)
Is = VsIs(2); Ism = 1000*abs(Is); % A (sending end current)
pfs= cos(angle(Vs)- angle(Is)); % (sending end power factor)
Ss = 3*Vs*conj(Is); % MVA (sending end power)
REG = (Vs3ph/abs(ABCD(1,1)) - VR3ph)/VR3ph *100;
fprintf(' Is = %g A', Ism), fprintf(' pf = %g\n', pfs)
fprintf(' Vs = %g L-L kV\n', Vs3ph)
fprintf(' Ps = %g MW', real(Ss)),
fprintf(' Qs = %g Mvar\n', imag(Ss))
fprintf(' Percent voltage Reg. = %g\n', REG)
Page 18
Result
Enter 1 for Medium line or 2 for long line --> 1
Nominal pi model
Is = 421.132 A pf =
0.869657 Vs = 345.002 L-L kV
Ps = 218.851 MW Qs = 124.23 Mvar
Percent voltage Reg. = 7.30913
Page 19
Date:
Experiment No. 5
MATLAB Program
if model==2
Z = Zc*sinh(Gamal); Y = 2*tanh(Gamal/2) /Zc;
else, end
Page 20
fprintf(' Z'' = %g + j ',real(Z)), fprintf('%g ohms\n',imag(Z)),
fprintf(' Y'' = %g + j ',real(Y)), fprintf('%g siemens\n',imag(Y))
fprintf(' Zc = %g + j ',real(Zc)), fprintf('%g ohms\n',imag(Zc))
fprintf(' alpha l = %g neper', real(Gamal))
fprintf(' beta l = %g radian', imag(Gamal))
fprintf(' = %g degree\n', imag(Gamal*180/pi))
else, end,
% end
end
if model == -1 | model == 1 | model == 2
% A,B,C,D constants of line
A = 1 + Z*Y/2; B = Z;
C = Y*(1 + Z*Y/4); D = A;
ABCD = [A B; C D];
disp(' ')
fprintf(' %-11.5g + j', real(A)), fprintf(' %-11.5g', imag(A))
fprintf(' %-11.5g + j', real(B)), fprintf(' %-11.5g \n', imag(B))
fprintf(' ABCD =
\n')
fprintf(' %-11.5g + j', real(C)), fprintf(' %-11.5g', imag(C))
fprintf(' %-11.5g + j', real(D)), fprintf(' %-11.5g \n', imag(D))
else, fprintf(' You must enter 1 or 2. Tray again \n'), return, end
Result
ABCD =
Z =
10.8778 +98.3624i
Y =
0.0000 + 0.0010i
Page 21
Date:
Consider a transmission line model with a simple series RL circuit. Let R=0.125 ohms, L=10mH, and the
source voltage is given by v(t) = 151 sin (377t+α). Determine the current response after closing the switch for
the following cases.
(a) No dc offset
(b) For maximum dc offset
Now create a file name ‘Experiment6.m’ and save the following. Execute it.
gamma=88.1*pi/180;
alpha1=88.1*pi/180;
alpha2=1.9*pi/180;
t=0:0.001:0.3;
i1=40*sin(377*t+alpha1 -gamma)-40*exp(-t/.08).*sin(alpha1-gamma);
i2=40*sin(377*t+alpha2 -gamma)-40*exp(-t/.08).*sin(alpha2-gamma);
subplot(2,1,1), plot(t, i1), grid
xlabel('t, sec'), ylabel('i(t)')
subplot(2,1,2), plot(t, i2), grid
xlabel('t, sec'), ylabel('i(t)')
subplot(111);
The output is
Page 22
Date:
The function iprime = symshort(t, i) defines the differential equations of the synchronous machine during a
balanced three-phase fault. The function returns the state derivatives of the current.
Save the following function in the file name as ‘symshort.m’
0.0070;
Page 23
R= [ra 0 0 w*Lq w*k*MQ
0 rF 0 0 0
0 0 rD 0 0
-w*Ld -w*k*MF -w*k*MD ra 0
0 0 0 0 rQ];
L =[Ld k*MF k*MD 0 0
k*MF LF MR 0 0
k*MD MR LD 0 0
0 0 0 Lq k*MQ
0 0 0 k*MQ LQ];
Li=inv(L);
iprime=- Li*V - Li*R*i;
Now create a file name ‘Experiment7.m’ and save the following. Execute it.
fprintf('\n Wait simulation is in process. \n')
VF = 400; rF = 0.4; iF0 = VF/rF;
f = 60; w=2.*pi*f;
d = 0; d=d*pi/180;
t0 = 0 ; tfinal = 0.80;
i0 = [0; iF0; 0; 0; 0 ]; % Initial currents
tspan = [t0, tfinal];
[t, i] = ode45('symshort', tspan, i0);
theta = w*t+d +pi/2;
ia = sqrt(2/3)*(cos(theta).*i(:,1)+sin(theta).*i(:,4));
ib = sqrt(2/3)*(cos(theta-2*pi/3).*i(:,1)+sin(theta-2*pi/3).*i(:,4));
ic = sqrt(2/3)*(cos(theta+2*pi/3).*i(:,1)+sin(theta+2*pi/3).*i(:,4));
iF = i(:,2); % ia = Armature current iF=Field current figure(1),
plot(t,ia), xlabel('t, sec'), ylabel('ia, A'), grid
title(['Three-phase short circuit ia, ','delta = ', num2str(d)])
figure(2), plot(t,ib), xlabel('t, sec'), ylabel('ib, A'), grid
title(['Three-phase short circuit ib, ','delta = ', num2str(d)])
Page 24
figure(3), plot(t,ic), xlabel('t, sec'), ylabel('i c, A'), grid
title(['Three-phase short circuit ic, ','delta = ', num2str(d)])
figure(4), plot(t,iF), xlabel('t, sec'), ylabel('iF, A'), grid
title(['Three-phase short circuit iF, ','delta = ',num2str(d)])
A fundamental-frequency component
A dc component
A double-frequency component.
Page 25
Page 26
Page 27
Date:
Experiment 8: Symmetrical Components from Unbalance Currents
Obtain the symmetrical components of a set of unbalanced currents –
Ia = 1.6 @ 25º, Ib = 1.0 @ 180º and Ic = 0.9 @ 132º.
This function transforms a three-phase unbalanced phasor into its symmetrical components. The Three phasors
can be expressed in a one column array in rectangular complex form or in a two column array in polar form,
with 1st column magnitude and 2nd column phase angle in degree.
The function returns the symmetrical components in rectangular form. The function plots the original
unbalanced phasors and the symmetrical components.
function [symcomp] = abc2sc(fabc)
rankfabc=length(fabc(1,:));
if rankfabc == 2
mag= fabc(:,1); ang=pi/180*fabc(:,2);
fabcr=mag.*(cos(ang)+j*sin(ang));
elseif rankfabc ==1
fabcr=fabc;
else
fprintf('\n Three phasors must be expressed in a one column array in
symcomp= fa012;
%scpolar = [abs(fa012) 180/pi*angle(fa012)];
%fprintf(' \n Symmetrical components \n')
%fprintf(' Magnitude Angle Deg.\n')
%disp(scpolar)
Page 28
fabc0=fa012(1)*[1; 1; 1];
fabc2=fa012(3)*[1; a; a^2];
figure
subplot(221);
[Px, Py, Vscale]= phasor3(fabcr);
[Px0, Py0, Vscale0]= phasor3(fabc0);
[Px1, Py1, Vscale1]= phasor3(fabc1);
[Px2, Py2, Vscale2]= phasor3(fabc2);
Vscle=max([Vscale, Vscale0, Vscale1, Vscale2]);
plot(Px', Py','r')
title('a-b-c set')
axis([-Vscle Vscle -Vscle Vscle]);
axis('square')
subplot(222);
plot(Px0',
Py0','g')
title('Zero-sequence set')
axis([-Vscle Vscle -Vscle Vscle]);
axis('square')
subplot(223);
plot(Px1',
Py1','m')
title('Positive-sequence set')
axis([-Vscle Vscle -Vscle Vscle]);
axis('square')
subplot(224);
plot(Px2',
Py2','b')
title('Negative-sequence set')
Page 29
axis([-Vscle Vscle -Vscle Vscle]);
axis('square')
subplot(111)
Page 30
% The function returns the symmetrical components in polar form
function Fpol = rec2pol(Frec)
Fpol = [abs(Frec) angle(Frec)*180/pi];
Create the main file by name ‘Experiment8.m’and save the following. Execute it.
Iabc = [1.6 25
1.0 180
0.9 132];
I012 = abc2sc(Iabc); % Symmetrical components of phase a
I012p= rec2pol(I012) % Converts rectangular phasors into polar form
Result in
I012p =
0.4512 96.4529
0.9435 -0.0550
0.6024 22.3157
Page 31
Date:
This function transforms the symmetrical components into its original abc phasors. The symmetrical
components can be expressed in a one column array in rectangular complex form or in a two column array in
polar form, with 1st column magnitude and 2nd column phase angle in degree.
First, second and third rows are Zero-, positives- and negative-sequence components respectively. The function
returns the abc phsors in rectangular form. The function plots the original symmetrical components and the
unbalanced phasors.
if rankf012 == 2
mag= fa012(:,1); ang=pi/180*fa012(:,2);
fa012r=mag.*(cos(ang)+j*sin(ang));
elseif rankf012 ==1
fa012r=fa012;
else
fprintf('\n Symmetrical components must be expressed in a one column
Page 32
fabc2=fa012r(3)*[1; a; a^2];
figure
subplot(221);
[Px, Py, Vscale]= phasor3(fabc);
[Px0, Py0, Vscale0]= phasor3(fabc0);
[Px1, Py1, Vscale1]= phasor3(fabc1);
[Px2, Py2, Vscale2]= phasor3(fabc2);
Vscle=max([Vscale, Vscale0, Vscale1, Vscale2]);
plot(Px', Py','r')
title('a-b-c set')
axis([-Vscle Vscle -Vscle Vscle]);
axis('square')
subplot(222);
plot(Px0',
Py0','g')
title('Zero-sequence set')
axis([-Vscle Vscle -Vscle Vscle]);
axis('square')
subplot(223);
plot(Px1',
Py1','m')
title('Positive-sequence set')
axis([-Vscle Vscle -Vscle Vscle]);
axis('square')
subplot(224);
plot(Px2',
Py2','b')
title('Negative-sequence set')
axis([-Vscle Vscle -Vscle Vscle]);
axis('square')
Page 33
subplot(111)
Page 34
% The function returns the symmetrical components in polar form
function Fpol = rec2pol(Frec)
Fpol = [abs(Frec) angle(Frec)*180/pi];
Create the main file by name ‘Experiment9.m’and save the following. Execute it.
V012 = [.6 90
1 30
0.8 -30];
Vabc = sc2abc(V012); % Unbalanced phasors from symmetrical components
Vabcp= rec2pol(Vabc) % Converts rectangular phasors into polar form
Results in
Vabcp =
1.7088 24.1825
0.4000 90.0000
1.7088 155.8175
Page 35