Borrar filtros
Borrar filtros

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

3 visualizaciones (últimos 30 días)
AleF
AleF el 26 de Mzo. de 2023
Comentada: AleF el 27 de Mzo. de 2023
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!

Respuesta aceptada

Matt J
Matt J el 26 de Mzo. de 2023
Editada: Matt J el 26 de Mzo. de 2023
I would just compute the Jacobian matrix of the spherical to cartesian coordinate transformation and multiply the spherical gradients by that.

Más respuestas (0)

Categorías

Más información sobre Resizing and Reshaping Matrices en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by