Reputation: 51
I want to compute the gradient of the electrostatic potential of combination of 4 charges located at (1,1,0)
, (1,-1,0)
, (-1,1,0)
and (-1,-1,0)
. How can I use the symbolic toolbox in MATLAB to achieve this?
Upvotes: 0
Views: 1009
Reputation: 42225
My electromagnetics is rusty, but your question has a simple analytical solution.
The electric potential is:
and this is what it looks like on the plane z=0
Now the gradient is
and noting that
you can easily apply the above to all the terms in the equation of the gradient to get a closed form solution that can be easily plotted.
Here's an example that shows you how to perform the above partial differentiation in MATLAB. You can then build upon this to derive the full solution. I'll leave that upto you.
syms x y z x0 y0 z0
diff(1/sqrt((x-x0)^2+(y-y0)^2+(z-z0)^2),x)
ans =
-(x - x0)/((x - x0)^2 + (y - y0)^2 + (z - z0)^2)^(3/2)
Upvotes: 2