Calculate 3D gradient of data corrisponding to a non-uniform grid
3 次查看(过去 30 天)
显示 更早的评论
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!
0 个评论
采纳的回答
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Resizing and Reshaping Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!