How can I plot y-z plane slices in a 3D volume?

60 visualizaciones (últimos 30 días)
Nathan Lauer
Nathan Lauer el 3 de Mayo de 2016
Comentada: Josh el 11 de Dic. de 2020
I have a series of plots representing the vorticity field behind an aircraft wing, at various downstream distances. Each is a 2D plot, and I would like to display them in 3D, one behind the other, in order to get a full 3D sense of the vorticity field behind the wing. In my first attempt, I made a 3D meshgrid, set it to zero, and filled in 4 z-slices with 4 vorticity plots, and that worked. However, I could not get it to the viewpoint that I wanted. Here is the plot that resulted:
This is rather confusing because in this plot, the wing is beneath the plot, and therefore is more likely to confuse the intended audience than do any good. Further, in attempting to change the viewing angle with Matlab's view command, I was not able to get to the desired viewing angle.
So then I made a second attempt, where instead of plotting z-slices I plot x-slices. This does indeed give me the desired viewing angle, as seen here (where the slices are just zeros):
Here, the wing is to the left of the plot, and it's much easier for the audience to get a sense of the full 3D vorticity field. However, I am unable to get the vorticity plots to display. Here is my code:
FullVectorField = zeros(200,14,13);
[x,y,z] = meshgrid(1:1:14, 1:1:200, 1:1:13);
FullVectorField(50,:,:) = vorticity70;
FullVectorField(100,:,:) = vorticity80;
FullVectorField(150,:,:) = vorticity90;
FullVectorField(200,:,:) = vorticity100;
zslice = [];
xslice = [50,100,150,200];
yslice = [];
A = FullVectorField(50,:,:);
figure
slice(x,y,z,FullVectorField,xslice,yslice,zslice);
pbaspect([3 1 1])
axis([0, 200, 0, 14, 0, 13])
colormap jet
colorbar
xlabel('x axis (cm)')
ylabel('y axis (cm)')
zlabel('z axis (cm)')
vorticity70, vorticity80, etc are the matrices containing the data points I would like to plot. Any help in getting the vorticity plots to display along the xslices? Thanks!

Respuesta aceptada

Mike Garrity
Mike Garrity el 3 de Mayo de 2016
Editada: Mike Garrity el 3 de Mayo de 2016
You don't really need to build a full 3D array and then slice it. You can just place individual 2D slices in a 3D axes.
[y,z] = meshgrid(linspace(0,10,40));
for off=50:50:200
x = off + zeros(size(z));
% My standin for your vorticity data
c = cos((x+y)/5) .* cos((x+z)/5);
surf(x,y,z,c)
hold on
end
hold off
xlim([0 200])
  4 comentarios
adi
adi el 16 de Dic. de 2019
hey,
i have the exact problem you just described...do you know how to fix this?
thanks

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by