0% found this document useful (0 votes)
16 views

Report Form

The document discusses plotting the potential surface and electric field strength vectors in the Oxy plane using MATLAB. It provides background on electric fields, describes the MATLAB code used, and gives an example where the potential is V(x,y)=100x+y. The results from the MATLAB code are shown to match analytical calculations.

Uploaded by

Như Vũ
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Report Form

The document discusses plotting the potential surface and electric field strength vectors in the Oxy plane using MATLAB. It provides background on electric fields, describes the MATLAB code used, and gives an example where the potential is V(x,y)=100x+y. The results from the MATLAB code are shown to match analytical calculations.

Uploaded by

Như Vũ
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

VIET NAM NATIONAL UNIVERSITY HO CHI MINH CITY

UNIVERSITY OF TECHNOLOGY

-------------***----------------

Physics
Matlab Project
Topic: Plot the potential surface and electric field strength vectors in the
Oxy plane
Group 07
Team members:
1. Nguyễn Minh Quân 2152920
2. Dương Trọng Phúc 2152237
3. Vũ Nguyên Quỳnh Như 2053309

Semester: HK211
Lecturer: Đỗ Ngọc Sơn & Nguyễn Trung Hậu
Submission date:
Plot the potential surface and electric field strength vectors
in the Oxy plane
1. Introduction

Electric field E , a vector quantity, is the force per unit charge exerted on a test charge at any point.The
electric field produced by a point charge is directed radially away from or toward the charge.

Figure 1:The field produced by a positive point charge


points away from the charge.

Figure 2: The field produced by a negative point charge


points toward the charge.
→ →
We define the electric field E at a point as the electric force F experienced by a test charge q0 at the
0
point, divided by the charge q0 .That is, the electric field at a certain point is equal to the electric force
per unit charge experienced by a charge at that point:


F0
E=
q0

while : E is Electric field


F 0 is Electric force on a test charge q0 due to other charges
q 0 is value of test charge

In SI units, in which the unit of force is 1 N and the unit of charge is 1 C, the unit of electric-field
magnitude is 1 newton per coulomb 1(N/C)

If we place a small test charge q0 at the field point P, at a distance r from the source point q, the
magnitude F0 of the force is given by Coulomb’s law:

1 |q q0|
F 0=
4 π ε0 r 2
The magnitude E of the electric field at P is

1 |q|
E= (magnitude of electric field of a point charge)
4 π ε0 r2

Using the unit vector r , we can write a vector equation that gives both the magnitude and direction of

the electric field E :


1 q→
E= r
4 π ε0 r3

while : E is Electric field due to a point charge

1
=k : electric constant ;( k = 9 x 109 N.m2/C2)
4 π ε0

q is value of point charge

r is the distance from point charge to where field is measured



r is unit vector from point charge toward where field is measured
Work done by the electric force is not dependent on the path but on the initial and final positions=>
Electric force is conservative.

The work done by electric force equal to the decrease of potential energy .
→ → q q0 q q0
dW =F . d S =k 2
ds . cos θ=k 2
dr
r r
rB
→ →
q q0 q q0 qq
⇒ W AB= ∫ F . d S =∫ k
r
2
dr =k
rA
−k 0
rB
A→B rA

q q0
U ( r )=k +C : Potential energy of system of 2 point charges
r
W AB =U A −U B =−△ U

r =∞ ,U =0 ⇒ C=0
Electric Potential at M due to a point charge q :

U (r ) q
V ( r )= =k +C
q0 r

Electric Potential Due to Continuous Charge Distributions:

q
V =k +C ; V ( ∞ ) ⇒ C=0
r
dq
Divide → dq →dV =k
r

dq
V ( M )= ∫ dV = ∫ k
r
( object ) ( object )
2. Theory

Relationship between E and V

Work done by the electric force = decrease in the potential energy

→ → → →
dW =F . d S =q0 E . d S =−dU
→ →
U dU
V= ⇒ dV = =−E . d S =−ES dS
q0 q0
−dV
E S=
ds
−dV −dV −dV
⇒ E x= ; E y= ; Ez=
dx dy dz

( )
→ →
∂V → ∂V → ∂V →
E =−grad V =− e + e + e
∂x x ∂ y y ∂z z

3. MATLAB Code and Explanation

clf % Clear figure

syms x y real %Initialize variables

V= input('Enter potential V(x,y) as an equation, V(x y)= '); %Enter potential


V(x,y) as an equation

[X, Y]= meshgrid(-10:1:10); %Returns 3-D grid coordinates defined by the


vectors x, y, and z

Ex= zeros(size(X)); Ey= zeros(size(X)); Z= zeros(size(X)); %Returns an array


the same size as X consisting of all zeros

%@ Loop over all grid points and evaluate V(x,y) and E(x,y) on grid

for i= 1:size(X, 1) %size(X,1) is the number of rows 1 in the array "X" ;


% Let i run from 1 to the number of rows 1 in the array "X"

for j = 1: size(X, 2) %size(X,2) is the number of rows 2 in the array "X"

% Let j run from 1 to the number of rows 2 in the array "X"

%@ Evaluate electric field as Ex = (-1)*dV/dx and Ey = (-1)*dV/dy

Ex(i, j)= - subs(diff(V, x), {x y}, {X(i, j) Y(i, j)});

Ey(i, j)= - subs(diff(V, y), {x y}, {X(i, j) Y(i, j)});

Z(i, j)= subs(V, {x y}, {X(i, j) Y(i, j)});

if imag(Z(i, j)) ~= 0 %"imag(Z(i, j))":returns the imaginary part of


each element in array Z(i, j)

%If the imaginary part of each element in array Z(i, j)

%approximately equal to 0 then

Z(i, j)= 0;

Ex(i, j)= 0;

Ey(i, j)= 0;

end

end

end

%@ Plot electric potential and electric field

subplot(1, 2, 1); surf(X, Y, Z); title('Electric Potential')

subplot(1, 2, 2); quiver(X, Y, X + Ex, Y +Ey);title ('Electric Field')

4. Results and discussion

Example : For potentials V(x,y)= 100*x + y


Above results exactly match the results manually calculated. With Matlab calculation, we can replace
appropriately many others values of quantities to study other special cases.

5. Conclusion

The project has completed the plot of the potential surface and electric field strength vectors in the Oxy
plane problem using MATLAB symbolic calculation. With this tool we can solve more complex motion
situations that cannot be solved by the analytical method.

References:

[1] A. L. G. a. C. Penland, "MATLAB Projects for Scientists and Engineers," 1996. [Online].
Available: http://www.algarcia.org/fishbane/fishbane.html.
[2] R. A. F. Hugh D. Young, University Physics with Modern Physics, Pearson Education, 2016.
[3] R. R. J. W. David Halliday, Fundamentals of Physics Extended 10th edition, 2013.

You might also like