Compute Gradient of a Scalar 3-D Field Defined On a non Uniform Grid

조회 수: 6 (최근 30일)
Alessandro
Alessandro 2017년 3월 31일
댓글: darova 2021년 3월 26일
I have the values of a scalar Field in 3 dimensions over a randomly arranged set of points in space. How do I calculate the components of the gradient of such function at the same point locations?

답변 (2개)

Ramesh Rajesh
Ramesh Rajesh 2021년 3월 25일
Did you manage to figure out ? I have same question.

darova
darova 2021년 3월 25일
What about griddata?
% assume x,y,z are your random coordinates
% assume u,v,w are your vectors (gradients)
% assume that you can interpolate Z variable
xx = linspace(min(x(:)),max(x(:)),20);
yy = linspace(min(y(:)),max(y(:)),20);
[x1,y1] = meshgrid(xx,yy); % create regular mesh
z1 = griddata(x,y,z,x1,y1); % interpolate Z coordinate
u1 = griddata(x,y,u,x1,y1); % interpolate gradient U
v1 = griddata(x,y,v,x1,y1); % interpolate gradient V
w1 = griddata(x,y,w,x1,y1); % interpolate gradient W
  댓글 수: 2
Ramesh Rajesh
Ramesh Rajesh 2021년 3월 26일
Thanks for your code. I have data of coordinates in X,Y,Z with a scalar value. The locations of X,Y,Z are random. How do I find gradients (u,v,w) of the random coordinates?
darova
darova 2021년 3월 26일
Find then use surfnorm
h = surf(x1,y1,z1);
[u,v,w] = surfnorm(h);

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Interpolation에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by