How to find gradient of a vector field in matlab symbolic
조회 수: 38 (최근 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!