Visualize 3D domain
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
What I am interested, however, is to visualize the 3D domain.
Now, the code itself is not the actual implementation, but it makes easier to explain. Say I want to visualize a 3D domain (like a 3D mesh) in polar coordinates.
The 3 spatial coordinates are
, and the z coordinate changes as a function of the other variables, ie,
.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/282882/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/282883/image.png)
clc; clear; close all force;
r = 1:0.2:2; % r coordinate discretization, from ri=1 to ro=2
theta = 0:pi/32:pi/4; % theta coordinate discretization, from theta_i = 0 to theta_o = pi/4
z = 0:0.2:1; % z coordinate discretization, from 0 to z_max, z_max = z(r,theta)
[R,Theta,Z] = ndgrid(r,theta,z);
figure; hold on;
for n=1:size(Z,3)
z_max = 1+Theta(:,:,1)/theta(end);
Z(:,:,n) = z(n)*z_max;
mesh(R(:,:,n),Theta(:,:,n),Z(:,:,n),'FaceAlpha',0.5,'edgecolor',[0.5 0.5 0.5])
end
xlabel('r')
ylabel('\theta')
zlabel('z')
view(3)
Now, the code above produces the following figure:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/282884/image.png)
This is almost what I want, but not exactly what I want. It sure helps to visualize the 3D domain, but I would like to also add the edge lines in the z direction, to create 3D cube-like shapes
Each vertex of the above grids is a vertex for a cube. Maybe a for loop could help to create this 3D mesh domain, but I don't know how.
Notice this is not the function itself I want to plot. Say, I have a dependent variable
, so I could use the methods described in volume visualizations to visualize 4D data. What I want to plot is the 3D mesh
that are the spatial variables and the domain of ϕ.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/282885/image.png)
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/282886/image.png)
Is the multifaceted patch a solution to the problem or is there a better solution to it?
0 Commenti
Risposte (0)
Vedere anche
Categorie
Scopri di più su Polygons in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!