How to find the gradient of a function in spherical coordinates system ?

15 ビュー (過去 30 日間)
Aswin K P
Aswin K P 2019 年 3 月 29 日
回答済み: Stephan 2019 年 3 月 31 日
For example a scalar field in Cartesian coordinates system A=x^2*y+x*y*z So, if we differentiate this entire equation with respect to x, y and z and add them then we will get the answer 3*X*y+x*z+y*z+x^2. But when we calculate the gradient the correct value should be (2*x*y+y*z)ax+(x^2+X*z)ay+(x*y)az
So can anybody please tell me the proper and correct method to find the gradient in spherical coordinates system

回答 (1 件)

Stephan
Stephan 2019 年 3 月 31 日
Hi,
take advantage of the gradient function:
syms x y z
A = x^2*y+x*y*z
res = gradient(A,[x y z])
results in:
res =
2*x*y + y*z
x^2 + z*x
x*y
Best regards
Stephan

カテゴリ

Help Center および File ExchangeMathematics についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by