I’d like to know how to draw a graph with 2 electric charges Q and -Q and their total E, for a specific point (eg (4,5)), with contour f..
My M-file actually scans the area (from -3x to 3x) and calculates E for every spot, stores it in a table, but after this, I don’t know how to use contourf to draw it..
syms i
syms j
syms d
d=input('dwse thn timi tou d,ths apostashs')
j=0
i=0
for j=-d:d/1000:d
j=j+1
for i=-d:d/1000:d
i=i+1
z=(i,j)
end, end
Based on Coulomb’s law, the electric field created by a single, discrete charge q at a distance r is given by:
E=q/(4*pi*e0*r.^2);
If you have several charges you can use the superposition principle and add the contribution of each charge.
The only thing left to do is to create a grid to compute the electrical field. For this you can use tha Matlab function
meshgrid.A simple example in Matlab would be:
Hope it helps you. You can read the documentation of
contourfto tweak the plot to your needs.