NK Emt Practical PDF
NK Emt Practical PDF
NK Emt Practical PDF
PRACTICAL FILE
FOR
ELECTROMAGNETICS
SUBMITTED BY:-
VIKRAM BHARDWAJ
XO-473
BSc(H) ELECTRONICS Vth semester
1. Write a program in scilab to evaluate summation of two vectors A=3a x
and B=4a y . Plot the resultant C =A B and D=A B
PROGRAM:-
A=[3,0]
B=[0,4]
C=A+B
disp(C)
D=A-B
disp(D)
x=0:C(1)
Yc=(C(2)/C(1))*x
subplot(1,2,1)
plot(x,Yc)
x=0:D(1)
Yd=(D(2)/D(1))*x
subplot(1,2,2)
plot(x,Yd)
OUTPUT:-
3. 4.
3. -4.
Plot:-
2. 2. For the given two vectors A=4a x 2a y 6az and B =12a x 18a y 8az ,
write a program in scilab to evaluate the following:
i. A 3B
ii. 2A 5B
B
iii. A B
iv. A B
v. Find the angle between the two vectors A and B
PROGRAM:-
(i) A=[4,-2,6]
B=[12,18,-8]
C=A-3*B
disp(C)
OUTPUT:-
-32. -56. 30.
(ii) A=[4,-2,6]
B=[12,18,-8]
C=(2*A+5*B)/norm(B)
disp(C)
OUTPUT:-
2.9481739 3.7285729 -1.213954
(iii) A=[4,-2,6]
B=[12,18,-8]
C=A*B'
disp(C)
OUTPUT:-
-36.
(iv) A=[4,-2,6]
B=[12,18,-8]
C=cross(A,B)
disp(C)
OUTPUT:-
-92. 104. 96.
(v) A=[4,-2,6]
B=[12,18,-8]
theta=acosd((A*B')/(norm(A)*norm(B)))
disp(theta)
OUTPUT:-
102.03859
3. Write a program in scilab to find the GRADIENT of scalar function
( x, y, z ) xy yz xz at point (1, 2, 3).
PROGRAM:-
function A=f(x, y, z)
A=(x*y)+(y*z)+(x*z)
endfunction
function dA=g(x, y, z)
dA=numderivative(list(f,y,z),x)
endfunction
function B=h(y, z, x)
B=(x*y)+(y*z)+(x*z)
endfunction
function dB=i(x, y, z)
dB=numderivative(list(h,z,x),y)
endfunction
function C=j(z, x, y)
C=(x*y)+(y*z)+(x*z)
endfunction
function dC=k(x, y, z)
dC=numderivative(list(j,x,y),z)
endfunction
function G=GRAD(x, y, z)
G=[g(x,y,z),i(x,y,z),k(x,y,z)]
endfunction
disp("GRADIENT AT (1,2,3) IS")
disp(GRAD(1,2,3))
OUTPUT:-
5. 4. 3.
4. Write a program in scilab to find the DIVERGENCE of a vector field
A( x, y, z ) yzax 4 xya y yaz at (1, -2, 3).
PROGRAM:-
function Ax=f(x, y, z)
Ax=y*z
endfunction
function dAx=g(x, y, z)
dAx=numderivative(list(f,y,z),x)
endfunction
function Ay=h(y, z, x)
Ay=4*x*y
endfunction
function dAy=i(x, y, z)
dAy=numderivative(list(h,z,x),y)
endfunction
function Az=j(z, x, y)
Az=y
endfunction
function dAz=k(x, y, z)
dAz=numderivative(list(j,x,y),z)
endfunction
function D=DIV(x, y, z)
D=g(x,y,z)+i(x,y,z)+k(x,y,z)
endfunction
disp("DIVERGENCE AT (1,-2,3) IS")
disp(DIV(1,-2,3))
OUTPUT:-
4.
5. Write a program in scilab to
i. Find the CURL of a vector field A( x, y, z ) yzax 4 xya y yaz at (1, -2, 3)
PROGRAM:-
Azy=y
endfunction
function dAzy=g(x, y, z)
dAzy=numderivative(list(f,z,x),y)
endfunction
function Ayz=h(z, x, y)
Ayz=4*x*y
endfunction
function dAyz=i(x, y, z)
dAyz=numderivative(list(h,x,y),z)
endfunction
function Axz=j(z, x, y)
Axz=y*z
endfunction
function dAxz=k(x, y, z)
dAxz=numderivative(list(j,x,y),z)
endfunction
function Azx=l(x, y, z)
Azx=y
endfunction
function dAzx=m(x, y, z)
dAzx=numderivative(list(l,y,z),x)
endfunction
function Ayx=n(x, y, z)
Ayx=4*x*y
endfunction
function dAyx=o(x, y, z)
dAyx=numderivative(list(n,y,z),x)
endfunction
function Axy=p(y, z, x)
Axy=y*z
endfunction
function dAxy=q(x, y, z)
dAxy=numderivative(list(p,z,x),y)
endfunction
function Cx=CURLx(x, y, z)
Cx=(g(x,y,z)-i(x,y,z))
endfunction
function Cy=CURLy(x, y, z)
Cy=(k(x,y,z)-m(x,y,z))
endfunction
function Cz=CURLz(x, y, z)
Cz=(o(x,y,z)-q(x,y,z))
endfunction
function C=CURL(x, y, z)
C=[CURLx(x,y,z),CURLy(x,y,z),CURLz(x,y,z)]
endfunction
disp(CURL(1,-2,3))
OUTPUT:-
1. -2. -11.
(ii)
function Azy=f(y, z, x)
Azy=x*cos(x*z)
endfunction
function dAzy=g(x, y, z)
dAzy=numderivative(list(f,z,x),y)
endfunction
function Ayz=h(z, x, y)
Ayz=x
endfunction
function dAyz=i(x, y, z)
dAyz=numderivative(list(h,x,y),z)
endfunction
function Axz=j(z, x, y)
Axz=y+z*cos(x*z)
endfunction
function dAxz=k(x, y, z)
dAxz=numderivative(list(j,x,y),z)
endfunction
function Azx=l(x, y, z)
Azx=x*cos(x*z)
endfunction
function dAzx=m(x, y, z)
dAzx=numderivative(list(l,y,z),x)
endfunction
function Ayx=n(x, y, z)
Ayx=x
endfunction
function dAyx=o(x, y, z)
dAyx=numderivative(list(n,y,z),x)
endfunction
function Axy=p(y, z, x)
Axy=y+z*cos(x*z)
endfunction
function dAxy=q(x, y, z)
dAxy=numderivative(list(p,z,x),y)
endfunction
function Cx=CURLx(x, y, z)
Cx=(g(x,y,z)-i(x,y,z))
endfunction
function Cy=CURLy(x, y, z)
Cy=(k(x,y,z)-m(x,y,z))
endfunction
function Cz=CURLz(x, y, z)
Cz=(o(x,y,z)-q(x,y,z))
endfunction
function C=CURL(x, y, z)
C=[CURLx(x,y,z),CURLy(x,y,z),CURLz(x,y,z)]
endfunction
disp(CURL(0,0,0))
OUTPUT:-
0. 0. 0.
6. Assume that there exists a surface that can be modeled with the
( x y2 )
equation S e
2
function a=f(x, y)
a=exp(-x*x-y*y);
endfunction
function da=g(x, y)
da=numderivative(list(f,y),x);
endfunction
b=exp(-x*x-y*y);
endfunction
function db=i(x, y)
db=numderivative(list(h,x),y)
endfunction
function G=GRAD(x, y)
G=[g(x,y),i(x,y)]
endfunction
disp(GRAD(1,1))
x=0:0.1:1
y=0:0.1:1
[X,Y]=meshgrid(x,y)
Ax=(-2*X)*exp(-X*X-Y*Y)
Ay=(-2*Y)*exp(-X*X-Y*Y)
champ1(x,y,Ax,Ay)
OUTPUT:-
-0.2706706 -0.2706706
PLOT:-
7. Write a program in scilab to find the divergence of the 2D vector field
A e ( r / ) r , where, r xax ya y and r x y , α = 1. Also plot the
2 2 2 2
function Ax=f(x, y)
Ax=x*exp(-x*x-y*y)
endfunction
function dAx=g(x, y)
dAx=numderivative(list(f,y),x)
endfunction
disp(g(1,1))
function Ay=h(y, x)
Ay=y*exp(-x*x-y*y)
endfunction
function dAy=i(x, y)
dAy=numderivative(list(h,x),y)
endfunction
disp(i(1,1))
function D=div(x, y)
D=g(x,y)+i(x,y)
endfunction
disp(div(1,1))
x=0:0.1:1
y=0:0.1:1
[X,Y]=meshgrid(x,y)
Ax=X*exp(-X*X-Y*Y)
Ay=Y*exp(-X*X-Y*Y)
champ1(x,y,Ax,Ay)
OUTPUT:-
-0.2706706
PLOT:-
8. Write a program in scilab to find the curl of the 2D vector field
A e( r / ) ( r ) , where, r xax ya y and r 2 x 2 y 2 , α = 1, ω = 2.
2
function Azy=f(y, z, x)
Azy=0;
endfunction
function dAzy=g(x, y, z)
dAzy=numderivative(list(f,z,x),y)
endfunction
function Ayz=h(z, x, y)
Ayz=2*x*exp(-x*x-y*y)
endfunction
function dAyz=i(x, y, z)
dAyz=numderivative(list(h,x,y),z)
endfunction
function cx=curlx(x, y, z)
cx=g(x,y,z)-i(x,y,z)
endfunction
function Axz=j(z, x, y)
Axz=-2*x*exp(-x*x-y*y)
endfunction
function dAxz=k(x, y, z)
dAxz=numderivative(list(j,x,y),z)
endfunction
function Azx=l(x, y, z)
Azx=0
endfunction
function dAzx=m(x, y, z)
dAzx=numderivative(list(l,y,z),x)
endfunction
function cy=curly(x, y, z)
cy=k(x,y,z)-m(x,y,z)
endfunction
function Ayx=n(x, y, z)
Ayx=2*x*exp(-x*x-y*y)
endfunction
function dAyx=o(x, y, z)
dAyx=numderivative(list(n,y,z),x)
endfunction
function Axy=p(y, z, x)
Axy=-2*x*exp(-x*x-y*y)
endfunction
function dAxy=q(x, y, z)
dAxy=numderivative(list(p,z,x),y)
endfunction
function cz=curlz(x, y, z)
cz=o(x,y,z)-q(x,y,z)
endfunction
function c=curl(x, y, z)
c=[curlx(x,y,z),curly(x,y,z),curlz(x,y,z)]
endfunction
disp(curl(1,1,0))
x=0:0.1:1
y=0:0.1:1
[X,Y]=meshgrid(x,y)
Ax=(-2*X)*exp(-X*X-Y*Y)
Ay=(2*X)*exp(-X*X-Y*Y)
champ1(x,y,Ax,Ay)
Cx=0
Cz=4*exp(-X*X-Y*Y)(-X*X-Y*Y+1)
champ1(x,y,Cx,Cz)
OUTPUT:-
0. 0. -0.8120117
PLOT:-
9. TO OBTAIN CONTOUR PLOT OF VECTOR FIELD A(x,y), WHERE
A(x,y) = (x^2*y) ax + (y^2*x) ay .
PROGRAM:-
x=0:0.1:1
y=0:0.1:1
[X,Y]=meshgrid(x,y)
Ax=(X^2)*Y
Ay=X*(Y^2)
champ(x,y,Ax,Ay)
PLOT:-
10. Consider an infinite line charge with uniform charge density ρL =12
mC/m. Write a program in scilab to evaluate the electric field intensity
at a point P. s=2m is the perpendicular distance from the line charge to
point P. Also the plot the variation of electric field intensity E with s.
PROGRAM:-
function Fx=E(s)
Fx=12/(2*%pi*8.85*10^(-12)*s)
endfunction
disp(E(2))
s=0:0.1:10
plot(s,E)
OUTPUT:-
1.079D+11
PLOT:-
11. Consider a finite sheet of charge on z=0 plane, 0≤x≤1, 0≤y≤1, with
charge density ρS = xy(x2 +y2 +25)3/2. Write a program in scilab to
(i) Find the electric field at (0,0,5).
(ii) Force experienced by a -1mC charge located at (0,0,5).
(iii) Total charge Q.
PROGRAM:-
(i)
function a=fx(x, y)
a=-9*x^2*y
endfunction
function a=fy(x, y)
a=-9*y^2*x
endfunction
function a=fz(x, y)
a=45*x*y
endfunction
Ex=int2d(X,Y,fx)
Ey=int2d(X,Y,fy)
Ez=int2d(X,Y,fz)
function a=E()
a=[Ex,Ey,Ez]
endfunction
disp(E())
OUTPUT:-
-1.5 -1.5 11.25
(ii)
function a=fx(x, y)
a=-9*x^2*y
endfunction
function a=fy(x, y)
a=-9*y^2*x
endfunction
function a=fz(x, y)
a=45*x*y
endfunction
Ex=int2d(X,Y,fx)
Ey=int2d(X,Y,fy)
Ez=int2d(X,Y,fz)
function a=E()
a=[Ex,Ey,Ez]
endfunction
disp(E())
function b=F()
b=-1*10^(-3)*E()
endfunction
disp(F())
OUTPUT:-
0.15 0.0015 -0.01125
(iii)
function b=q(x, y)
b=x*y*(x^2+y^2+25)^(3/2)
endfunction
Q=int2d(X,Y,q)
disp(Q)
OUTPUT:-
33.146691
12.Write a program in scilab to plot electric field due to a uniformly charged sphere
of radius a= 10 m. The volume charge density of a uniformly charged sphere is
V 10 nC/m3 for 0 r 15m .
PROGRAM:-
function A=f1(r)
A=(p*r)/(3*8.85*10^(-12))
endfunction
function B=f2(r)
B=(p*a^3)/(3*8.85*10^(-12)*r^2)
endfunction
p=10*10^(-9)
a=10
r=0:10
plot(r,f1)
r=10:15
plot(r,f2)
PLOT:-
13. Given the point P(-2,6,3) in cartesian coordinates, write a program in
scilab to express point P in cylindrical and spherical coordinates.
PROGRAM:-
x=-2
y=6
z=3
p=(x^2+y^2)^(1/2)
o=atand(y/x)
z=z
r=(x^2+y^2+z^2)^(1/2)
q=atand(p/z)
disp(p,o,z)
disp(r,q,o)
OUTPUT:-
cylindrical coordinates:-
6.3245553, -71.565051, 3
spherical coordinates:-
7, 64.623066, -71.565051
14. Given the point P(3, π/2, -1) in cylindrical coordinates, write a
program in scilab to express point P in cartesian and spherical
coordinates.
PROGRAM:-
p=3
q=90
z=(-1)
x=p*cos(q)
y=p*sin(q)
r=(x^2+y^2+z^2)^(1/2)
o=atand((x^2+y^2)^(1/2)/z)
A=[x y z]
disp(A)
B=[r o q]
disp(B)
OUTPUT:-
PROGRAM:-
r=10;
o=180/4
q=3*180/4
Br=10/r
Bo=r*cosd(o)
Bq=1
Bx=(Br*sind(o)*cosd(q)+Bo*cosd(o)*cosd(q)-Bq*sind(q))
By=(Br*sind(o)*sind(q)+Bo*cosd(o)*sind(q)+Bq*cosd(q))
Bz=(Br*sind(o)-Bo*sind(o))
B=[Bx By Bz]
disp(B)
OUTPUT:-
(-4.7426407 3.3284271 -4.2928932)
r=10;
o=180/4
q=3*180/4
Br=10/r
Bo=r*cosd(o)
Bx=(Br*sind(o)*cosd(q)+Bo*cosd(o)*cosd(q)-sind(q))
By=(Br*sind(o)*sind(q)+Bo*cosd(o)*sind(q)+cosd(q))
Bz=(Br*sind(o)-Bo*sind(o))
disp(Bx)
disp(By)
disp(Bz)
Bp=(Bx*cosd(q)+By*sind(q))
Bq=(Bx*(-sind(q))+By*cosd(q))
B=[Bp Bq Bz]
disp(B);
OUTPUT:-
(5.7071068 1 -4.2928932)
16.Given the vector A ya x ( x z )a y in cartesian coordinates, write a
program in scilab to express A in cylindrical and spherical coordinates.
Evaluate A in cartesian, cylindrical and spherical coordinates at point
P(-2,6,3)
PROGRAM:-
(i) Cartesian to cylindrical:-
x=-2;
y=6;
z=3;
phi=atand(y/x);
A=[y (x+z) 0]
T=[cosd(phi) sind(phi) 0;-sind(phi) cosd(phi) 0;0 0 1]
B=T*A'
disp(A);
disp(B);
OUTPUT:-
CARTESIAN:- A = (6 1 0)
CYLINDRICAL:- B = (0.9486833 6.0083276 0)
x=-2;
y=6;
z=3;
phi=atand(y/x);
s=((x^2)+(y^2))^(1/2);
theta=atand(s/z);
A=[y (x+z) 0]
T=[sind(theta)*cosd(phi) sind(theta)*sind(phi) cosd(theta);cosd(theta)*cosd(phi)
cosd(theta)*sind(phi) -sind(theta);-sind(phi) cosd(phi) 0]
B=T*A'
disp(A);
disp(B);
OUTPUT:-
CARTESIAN:- A = (6 1 0)
SPHERICAL:- B = (0.8571429 0.4065786 6.0083276)
17.
Write a program in scilab to express the vector
10
B (r , , ) a r r cos a a in Cartesian and cylindrical
r
coordinates. Find B(3,4,0) and B (5, 2, 2) .
PROGRAM:-
(i) Cartesian:-
x=-3
y=4
z=0
p=(x^2+y^2)^(1/2)
r=(x^2+y^2+z^2)^(1/2)
Br=10/r
Bo=r*(z/r)
Bq=1
Bx=(Br*(p/r)*(x/p)+Bo*(z/r)*(x/p)-Bq*(y/p))
By=(Br*(p/r)*(y/p)+Bo*(z/r)*(y/p)+Bq*(x/p))
Bz=(Br*(z/r)-Bo*(p/r))
B=[Bx By Bz]
disp(B)
OUTPUT:-
(-2, 1, 0)
(ii) Cylindrical:-
p=5
q=180/2
z=-2
r=(p^2+z^2)^(1/2)
s=((p^2+z^2)^(1/2))
Br=10/r
Bo=r*(z/s)
x=(Br*(p/s)*cosd(q)+Bo*(z/s)*cosd(q)-sind(q))
y=(Br*(p/s)*sind(q)+Bo*(z/s)*sind(q)+cosd(q))
Bz=(Br*(z/s)-Bo*(p/s))
Bp=(x*cosd(q)+y*sind(q))
Bq=(x*(-sind(q))+y*cosd(q))
B=[Bp Bq Bz]
disp(B);
OUTPUT:-
(-2.46, 1, 1.167)
18. Given the vector Q
z
2 2
cos a
sin a z sin a z in cylindrical
PROGRAM:-
p=4;
phi=270;
z=3;
s=p/((p^2+z^2)^(1/2))
A=[s*cosd(phi) -s*sind(phi) -s*z*sind(phi)]
theta=atand(A(1)/A(3))
T=[cosd(phi) -sind(phi) 0;sind(phi) cosd(phi) 0;0 0 1]
T1=[sind(theta)*cosd(phi) sind(theta)*sind(phi) cosd(theta);cosd(theta)*cosd(phi)
cosd(theta)*sind(phi) -sind(theta);-sind(phi) cosd(phi) 0]
B=T*A'
C=T1*B
disp(A);
disp(B);
disp(C);
OUTPUT:-
CYLINDRICAL:- A= 0. 0.8 2.4
CARTESIAN:- B= 0.8 0. 2.4
SPHERICAL:- C= 2.4 0. 0.8
19. The Electric field component of a wave propagating in free space is
given by:
E(z,t) 10cos(107 t z)a z V/m
iii. Determine H Vs z
PROGRAM:-
function E=f(z, t)
E=10*cos(10^(8)*t-B*z)
endfunction
E0=10
w=10^(8)
u0=((4*3.14)*10^(-7))
e0=((8.85)*10^(-12))
c=(1/(u0*e0)^(1/2))
B=w/c
n0=((u0/e0)^(1/2))
H0=E0/n0
function H=f1(z, t)
H=H0*cos(w*t-B*z)
endfunction
t=0
z=0:0.1:30
subplot(1,2,1)
plot(z,f)
z=0:0.1:30
subplot(1,2,2)
plot(z,f1)
disp(B)
disp(n0)
disp(H0)
OUTPUT:-
𝜷=0.3334007, 𝛈𝟎 =376.72391, 𝑯𝒚𝟎 =0.0265446
PLOT:-
20. A uniform plane wave propagating through a lossless (perfect)
dielectric medium with εr = 8, μr = 2 has
E 0.5sin(108 t z )a x V/m
Write a program in scilab to determine:
(a) β (propagation constant)
(b) η (characteristic impedance)
(c) vp (wave velocity)
(d) Plot E and H
PROGRAM:-
w=10^(8)
E0=0.5
er=8
ur=2
s=0
e0=(8.85*10^(-12))
u0=(4*3.14*10^(-7))
e=(e0*er)
u=(u0*ur)
v=(1/((u*e)^(1/2)))
b=(w/v)
n=((u/e)^(1/2))
H0=(E0/n)
t=0
z=0:0.1:10
E=0.5*cos(10^(8)*t-b*z)
H=H0*cos(w*t-b*z)
subplot(1,2,1)
plot(z,E)
z=0:0.1:10
subplot(1,2,2)
plot(z,H)
A=[e u v H0 b n]
disp(A)
OUTPUT:-
PLOT:-
21. A uniform plane wave of amplitude 10 V/m whose frequency is 300
MHz propagates in a lossy dielectric medium. The EF is polarized in the
x direction. If the medium is characterized by εr = 9, μr = 1 and α = 1/3
m-1. Plot E and H .
PROGRAM:-
f=300*10^(6)
w=2*3.14*f
E0=10
a=1/3
er=9
ur=1
s=10
e0=(8.85*10^(-12))
u0=(4*3.14*10^(-7))
e=(e0*er)
u=(u0*ur)
v=(1/((u*e)^(1/2)))
b=(w/v)
n=((u/e)^(1/2))
H0=(E0/n)
t=0
z=0:0.1:10
E=E0*exp(-a*z).*cos(w*t-b*z)
H=H0*exp(-a*z).*cos(w*t-b*z)
subplot(1,2,1)
plot(z,E)
z=0:0.1:10
subplot(1,2,2)
plot(z,H)
A=[e u v H0 b n]
disp(A)
OUTPUT:-
𝜷=18.843805, 𝛈𝟎 =125.57464, 𝑯𝒚𝟎 =0.0796339, e=7.965*10^(-11),
μ=0.0000013, v=99979806
PLOT:-
22. (i) A 10 V/m plane wave whose frequency is 300 MHz propagates in
the +z direction in a lossy/partially conducting medium. If the medium
is characterized by εr = 9, μr = 1 and σ = 10 S/m. Write a program in
scilab to evaluate skin depth of the given medium.
(ii) Write a program in scilab to evaluate skin depth of copper
medium for an EM wave propagating at frequency of 3 GHz. (μr = 1
and σ = 5.8 x 107 S/m).
PROGRAM:-
(i)
f=300*10^(6)
w=2*3.14*f
E0=10
a=1/3
er=9
ur=1
s=10
e0=(8.85*10^(-12))
u0=(4*3.14*10^(-7))
e=(e0*er)
u=(u0*ur)
v=(1/((u*e)^(1/2)))
b=(w/v)
g=((2/w*u*s)^(1/2))
n=((u/e)^(1/2))
H0=(E0/n)
t=0
z=0:0.1:10
E=E0*exp(-a*z).*cos(w*t-b*z)
H=H0*exp(-a*z).*cos(w*t-b*z)
subplot(1,2,1)
plot(z,E)
z=0:0.1:10
subplot(1,2,2)
plot(z,H)
A=[e u v H0 b n]
disp(A)
disp(g)
OUTPUT:-
g=0.0000001
𝜷=18.843805, 𝛈𝟎 =125.57464, 𝑯𝒚𝟎 =0.0796339, e=7.965*10^(-11),
μ=0.0000013, v=99979806
PLOT:-
(ii)
f=3000*10^(6)
w=2*3.14*f
ur=1
s=(5.8*10^(7))
u0=(4*3.14*10^(-7))
u=(u0*ur)
g=((2/w*u*s)^(1/2))
disp(g)
OUTPUT:-
g=0.0000879