How Can MATLAB Help in Plotting the Electric Field of a Charged Wire?

Click For Summary
SUMMARY

The discussion focuses on calculating the electric field generated by a truncated charged wire using MATLAB. The linear charge density is specified as ρ = 8 C/m, and the wire length is L = 1 m, positioned along the y-axis. The electric field equation derived is E = [ρ/(4∏εr)] [(sin β1 - sin β2) + (cos β1 - cos β2)], where β1 and β2 are angles related to the observation point. Participants express challenges in plotting the electric field using the MATLAB quiver command, particularly in generating accurate vector representations.

PREREQUISITES
  • Understanding of electric field calculations and linear charge density
  • Familiarity with MATLAB programming, specifically the quiver function
  • Knowledge of trigonometric functions and their application in physics
  • Basic concepts of numerical integration for evaluating electric field components
NEXT STEPS
  • Learn how to implement numerical integration in MATLAB for electric field calculations
  • Explore the MATLAB quiver function in detail for effective vector plotting
  • Study the derivation and application of electric field equations for charged wires
  • Investigate the use of meshgrid in MATLAB for creating coordinate grids
USEFUL FOR

Students and professionals in physics and engineering, particularly those involved in computational electromagnetism and MATLAB programming for visualizing electric fields.

killerdevil
Messages
19
Reaction score
0

Homework Statement




A straight wire of electric charge truncate to length L has a linear charge density of ρ= 8 C/m. Using a computational approach calculate the electric field due to the truncated line at any arbitrary point in space.

Consider L = 1 m, assume line lies along y-axis with the two ends at (0,−L / 2) and (0, L / 2) , and use the MATLAB command quiver to provide a vector plot of the electric field in the x-y plane for a range of −1 m < x < 1m and −1 m < y <1m

Homework Equations



The Attempt at a Solution



I have attempted at this question and got the following equation:

E = [ρ/(4∏εr)] [(sin β1 - sin β2) + (cos β1 - cos β2)]
- where β is the angle between an arbitrary point and the line.
- sine is in the x direction, cosine is in the y direction

in an attempt to get a value instead of an equation, i place point P at the corner of the "imaginary box" (since the limit given to me was a 1 by 1 box).

β1 = 56.3°
β2 = 26.6°


the problem is i don't know how am i suppose to continue.

worst of all, i don't get what i am suppose to expect from the graph and having no experience in MATLAB, i don't know how to plot it.

a sample code (as shown below) was given to me to analysis but when i tried playing around with the codes using my value, but i got a weird looking graph (not even having a single vector) was given to me.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Example: quiver command
% let's plot the function 1/x as quiver plot over an XY
% region in space
clear all % clear memory, etc
% choose a region over which to plot
[x,y]=meshgrid(0:1:10,0:1:10);
% let x cpt be just equal to 1/x
Ex=1./x;
% set y cpt to zero and remember to make matrix sizes all
% the same (X, Y, Ex and Ey)
Ey=0*y;
% plot as 2-D arrow plot using quiver mode
% (the 0 at the end just auto-scales arrows)
quiver(x,y,Ex,Ey,0);
% insert labels for axes and title
xlabel('x');ylabel('y');title('Example of using quiver plot')
% Export figure into JPG format
print -f1 -r300 -djpeg example_quiver
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
Physics news on Phys.org
Hi killer. You didn't really explain how you came up with a formula for vector components Ex(x,y) and Ey(x,y).

Are you supposed to use a "closed form" expression for these or are you to calculate them numerically in matlab? For example, I can fairly easily write them as a definite integral (which I could evaluate numerically in matlab) but I don't seem to be able to get anything simpler.

Start by clearly explaining exactly what expressions you are trying to use for the vector components Ex,Ey.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 16 ·
Replies
16
Views
1K
  • · Replies 13 ·
Replies
13
Views
3K
Replies
1
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 17 ·
Replies
17
Views
3K
Replies
1
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K