开发者

Deriving the gradient of a potential in MATLAB using symbolic toolbox?

I want to compute the gradient of the electrostatic potential of combination of 4 charges开发者_如何学Python 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?


My electromagnetics is rusty, but your question has a simple analytical solution.

The electric potential is:

Deriving the gradient of a potential in MATLAB using symbolic toolbox?

and this is what it looks like on the plane z=0

Deriving the gradient of a potential in MATLAB using symbolic toolbox?

Now the gradient is

Deriving the gradient of a potential in MATLAB using symbolic toolbox?

and noting that

Deriving the gradient of a potential in MATLAB using symbolic toolbox?

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.


In MATLAB:

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)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜