필터 지우기
필터 지우기

Calculate 3D gradient of data corrisponding to a non-uniform grid

조회 수: 3 (최근 30일)
AleF
AleF 2023년 3월 26일
댓글: AleF 2023년 3월 27일
Hi all,
In order to obtain a spherical 3D grid, I have generated an evenly-spaced azimuth-elevation-radius ndgrid and subsequently transformed it in cartesian coordinates using sph2cart. In this coordinates system, points are not evenly spaced.
[AZ_grid,EL_grid,R_grid]=ndgrid(AZ_vector,EL_vector,R_vector); % evenly spaced 3D grid
[X_grid,Y_grid,Z_grid]=sph2cart(AZ_grid,EL_grid,R_grid); %non-evenly spaced 3D grid
I have a 3D matrix P of values corresponding to these points in space. Obviously, if X_grid=[NxMxH], also P=[NxMxH].
I have to calculate the gradient of P along every direction. For the spherical case, I think I could write:
[G_AZ,G_EL,G_R]=gradient(P,AZ_spacing,EL_spacing,R_spacing);
as AZ_spacing,EL_spacing,R_spacing are constants.
How can I get the same result in cartesian coordinates (without using scatteredInterpolant or similar as it does not support code generation)? I tried to transform G_AZ,G_EL,G_R using sph2cart (as below), but I'm not sure the results obtained are the correct ones.
[GX,GY,GZ]=sph2cart(G_AZ,G_EL,G_R);
Thanks to anyone who can help me!

채택된 답변

Matt J
Matt J 2023년 3월 26일
편집: Matt J 2023년 3월 26일
I would just compute the Jacobian matrix of the spherical to cartesian coordinate transformation and multiply the spherical gradients by that.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by