Using Slice on a Cartesian Grid that was Generated in Cylindrical Coordinates
Afficher commentaires plus anciens
Hello,
I generate a grid in cylindrical coordinates:
phi_grid = 0:1:360 ;
rho_grid = 5.5:0.1:10;
z_grid = -4:0.1:4;
[Rho_grid,Z_grid,Phi_grid] = meshgrid(rho_grid,z_grid,phi_grid);%creating a grid from those axes
I then convert to spherical & cartesian coordinates for when I need them.
R_grid = (Rho_grid.^2 + Z_grid.^2).^(0.5);% computing a Rad value for each point
Theta_sys3_grid = acosd(Z_grid./R_grid);
x = R_grid.*sind(Theta_sys3_grid).*cosd(Phi_grid);
y = R_grid.*sind(Theta_sys3_grid).*sind(Phi_grid);
z = R_grid.*cosd(Theta_sys3_grid);
I then run code to produce a value at each of these points in the cartesian plane. This code operates on the spherical coordinates. That code is long and complicated, here is replacement
v = x.*exp(-x.^2-y.^2-z.^2);
I now want to make a slice of the this data in the cartesian plane
xslice = linspace(-6,10,20);
yslice = linspace(-6,10,40);
zslice = linspace(-4,4,40);
xslice = xslice';
zslice = zslice';
yslice = yslice';
figure()
slice(x,y,z,v,xslice,yslice,zslice)
And I am returned this error message: "Input grid is not a valid MESHGRID." This is not an issue that one normally has if their grid was created using meshgrid. However, I'm assuming that creating a grid in one coordinate system and then changing the coordinate system can make the data either not monotonic or not plaid, compromising its valuable MESHGRID attributes. What I think I'm looking for, is a way make my new grids monotonic and plaid so I can operate on them with slice and contour slice, or, alternative solutions
Thank you
pH
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Surface and Mesh Plots dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!