![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174237/image.png)
How can I plot y-z plane slices in a 3D volume?
60 ビュー (過去 30 日間)
古いコメントを表示
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:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163339/image.jpeg)
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):
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/163340/image.jpeg)
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!
0 件のコメント
採用された回答
Mike Garrity
2016 年 5 月 3 日
編集済み: Mike Garrity
2016 年 5 月 3 日
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])
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/174237/image.png)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Surface and Mesh Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!