- #1
killerdevil
- 20
- 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
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%