Download as pdf or txt
Download as pdf or txt
You are on page 1of 8

3rd

Year
(IV)
Electromagnetics
Practical

Name– Anshul Shukla


Roll No- 8031|Sem-V
Subject– Electromagnetics Practical
University Roll No. 19025558021
Experiment: 6
Aim: Write Scilab program to plot the radial profile of
electric field and electric potential due the following
charge distributions.

1.Point charge
2.Charged circular ring
3.Charged cylinder
4.Charged conducting sphere
5.Uniformly charged non-conducting sphere

Software Used: Scilab


Theory:
For a point charge, Electric Field and Electric Potential is defined as E=kq/((r)^2)
and V=kq/r here r refers to the distance from the point charge and q is the
magnitude of the charge. In the program, boundary of r is defined first and then
radial profile is plotted using plot2d command. For a charged circular ring Electric
field and Electric Potential is defined as: E=(k*q*x)./(4+x.^2)^1.5 and
V=(k*q)./((4+x.^2)^1.5) in the end the radial profile is plotted using plot2d
command. For charged solid non-conducting cylinder Electric Field inside the
cylinder is E1=2*k*L*x1./(r.^2) and outside the cylinder E2=2*k*L*(x2.^-1) and
Electric Potential is V2=-2*k*L.*log(x2), V1=-2*k*L*log(r) outside and inside the
cylinder respectively, finally radial profile is plotted using plot2d command. For a
charged conducting sphere Electric Field inside the sphere is 0 and outside the
sphere as E=k*q./(x2.^2) and Electric Potential inside the sphere is constant as
kq/r (here r=radius of the sphere) potential outside the sphere is kq/x (here x is
the distance from the sphere). In the program ones command is used to create a
matrix where each and every element is one to store a value which is constant
(zero in electric field and kq/r in potential). For a uniformly charged
non-conducting sphere Electric Field, E1=k*q.*x1/(r.^3) & E2=k*q./(x2.^2) here r
is the radius of sphere. P1=k*q.*(3*(r.^2)-(x1.^2))./(2.*(r.^3)) & P2=k*q./x2.
Finally, the radial profile using plot2d is plotted. In all these formulas, x1 is the
range of distance upto radius r and x2 is the range of distance outside the sphere.

Program:
Written Code:
clc
clf
clear
k=9e9
q=2
//r=linspace(0.001,0.01,30)
//E=(k*q)./(r.^2)
//P=(k*q)./(r)
//subplot(121)
//plot2d(r,E,2)
//xtitle("Radial Profile of Electric Field plot due to point
charge","Distance","Electric Field")
//subplot(122)
//plot2d(r,P,5)
//xtitle("Radial Profile of Electric Potential plot due to point
charge","Distance","Electric Potential")
//x=linspace(-20,20,100)
//r=2
//E=(k*q*x)./(4+x.^2)^1.5
//subplot(121)
//plot2d(x,E,2)
//P=(k*q)./((4+x.^2)^1.5)
//xtitle("Radial Profile of Electric Field plot due to circular ring
","Distance","Electric Potential")
//subplot(122)
//plot2d(x,P,2)
//xtitle("Radial Profile of Electric Potential plot due to circular ring
","Distance","Electric Potential")
//L=2
//r=4
//x1=linspace(0.001,r,50)
//x2=linspace(r,2*r,50)
//E1=2*k*L*x1./(r.^2)
//E2=2*k*L*(x2.^-1)
//subplot(121)
//plot2d(x1,E1,2)
//plot2d(x2,E2,3)
//xtitle("Radial Profile of Electric Field plot due to solid non conducting
cylinder ","Distance","Electric Field")
//P2=-2*k*L.*log(x2)
//P1=-2*k*L*log(r)
//subplot(122)
//plot2d(x2,P2,6)
//xtitle("Radial Profile of Electric Potential plot due to solid non
conducting cylinder ","Distance","Electric Potential")
//r=5
//x2=linspace(r,4*r,50)
//x1=linspace(0.001,r,50)
//E1=ones(1,50).*0
//E2=k*q./(x2.^2)
//subplot(121)
//plot2d(x1,E1,2)
//plot2d(x2,E2,5)
//xtitle("Radial Profile of Electric Field plot due to solid conducting
sphere ","Distance","Electric Field")
//P1=ones(1,50)*(k*q./r)
//P2=k*q./x2
//subplot(122)
//plot2d(x1,P1,2)
//plot2d(x2,P2,5)
////xtitle("Radial Profile of Electric Potential plot due to solid conducting
sphere ","Distance","Electric Potential")
r=5
x2=linspace(r,4*r,50)
x1=linspace(0.001,r,50)
E1=k*q.*x1/(r.^3)
E2=k*q./(x2.^2)
subplot(121)
plot2d(x1,E1,2)
plot2d(x2,E2,5)
xtitle("Radial Profile of Electric Field plot due to solid non conducting
sphere ","Distance","Electric Field")
P1=k*q.*(3*(r.^2)-(x1.^2))./(2.*(r.^3))
P2=k*q./x2
subplot(122)
plot2d(x1,P1,2)
plot2d(x2,P2,5)
xtitle("Radial Profile of Electric Potential plot due to solid non
conducting spher ","Distance","Electric Potential")

Output:
1.
2.

3.
4.

5.
Result:
Radial Profile is successfully plotted for the given figures
using Scilab.

Discussion:
1.Here we have assumed the radius and the range of distance
ourselves.
2.Ones command has been used indirectly to set the values of
Electric Field and Potential as a constant value.

Name: Anshul Shukla

Roll No. 8031

Electronics (Hons) IIIrd Year

You might also like