# Homework Help: MATLAB help needed for electric field plotting

1. Nov 26, 2012

### killerdevil

1. The problem statement, all variables and given/known data

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 2. Relevant equations

3. 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.

2. Nov 27, 2012

### uart

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.