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

Click For Summary
The discussion focuses on calculating the electric field generated by a charged wire using MATLAB, specifically for a wire with a linear charge density of 8 C/m and a length of 1 m. The user has derived an equation for the electric field but is unsure how to proceed with plotting it in MATLAB, particularly using the quiver command. There is confusion regarding the proper expressions for the vector components Ex and Ey, with suggestions that a numerical approach may be more effective than a closed-form expression. The user also expresses difficulty in interpreting the output of their MATLAB code, which resulted in an unexpected graph. Clarification on the calculation method and MATLAB implementation is sought to achieve a correct vector plot of the electric field.
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 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · 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