How to find gradient of a vector field in matlab symbolic
25 次查看(过去 30 天)
显示 更早的评论
I am trying to find gradient of a vector field in matlab symbolic , whose output will be matrix but it am getting error
2 个评论
采纳的回答
Walter Roberson
2023-12-12
移动:Walter Roberson
2023-12-12
The fundamental problem you are having is that gradient does not accept a vector the first parameter.
syms x y z
syms u(x,y,z) v(x,y,z) w(x,y,z)
V = [u(x,y,z) v(x,y,z) w(x,y,z)];
S = [x y z];
temp = arrayfun(@(EXPR) gradient(EXPR,S), V, 'uniform', 0);
result(x,y,z) = [temp{:}]
0 个评论
更多回答(2 个)
Sulaymon Eshkabilov
2023-12-12
If you assign an expression for V, you will get this:
clc ; clearvars
syms x y z
syms u(x,y,z) v(x,y,z) w(x,y,z)
V(x,y,z) = 2*u+3*v-w % Some e.g. expression
S = [x y z];
du = gradient(u,S)
dV = gradient(V,S)
% OR simply
dV= gradient(V,[x,y,z])
1 个评论
Dyuman Joshi
2023-12-12
V is not a combination of u, v and w, but an array with u, v and w as elements.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Symbolic Math Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!