我有一个数据文件,其中包含变量V
的x,y,z坐标x y z V
0 0 0.500000000000000 3.91743717285931
0.0500000000000000 0 0.500000000000000 4.82593865902504
0.100000000000000 0 0.500000000000000 5.03874568425820
0.150000000000000 0 0.500000000000000 4.84015746128314
0.200000000000000 0 0.500000000000000 4.31320834211277
0.250000000000000 0 0.500000000000000 4.71007310928003
0.300000000000000 0 0.500000000000000 5.68353172300361
0.350000000000000 0 0.500000000000000 6.93907354201857
0.400000000000000 0 0.500000000000000 1.69713115593222
0.450000000000000 0 0.500000000000000 0
0.500000000000000 0 0.500000000000000 0
0.550000000000000 0 0.500000000000000 0
0.600000000000000 0 0.500000000000000 0.485840981213434
0.650000000000000 0 0.500000000000000 1.30265381445392
0.700000000000000 0 0.500000000000000 1.73892191516507
0.750000000000000 0 0.500000000000000 1.78720066586633
0.800000000000000 0 0.500000000000000 0.401158585618868
0.850000000000000 0 0.500000000000000 4.33700792828408
0.900000000000000 0 0.500000000000000 5.76388423361443
0.950000000000000 0 0.500000000000000 2.41835943394263
因为包含值的数据文件都在不同的列中,我正在尝试将整个doamin转换为单个3d doamin。
input = importdata('lci_000210.dat',' ',3);
nx = 96;
ny = 96;
nz = 49;
x = input.data(:,1);
y = input.data(:,2);
z = input.data(:,3);
Lci = input.data(:,4);
L3d = reshape(Lci,[nx,ny,nz]);
x3d = reshape(x,[nx,ny,nz]);
y3d = reshape(y,[nx,ny,nz]);
z3d = reshape(z,[nx,ny,nz]);
[x3d,y3d,z3d,L3d] = flow;
xslice = 5;
yslice = 0;
zslice = 0;
slice(x,y,z,Lci,xslice,yslice,zslice);
view(25,20);
colormap jet
colorbar
然而,这会引发以下错误
V must be a 3-D array.
所以我真的不确定如何处理数据集,我真正想要的是通过数据集在任何位置切片,但仍然显示3d doamin。我附上了一张图片,展示了我希望如何表示切片。我已经尝试重新塑造,但这不起作用,我jave完成重新塑造,因为数据在列中并重新形状将其转换为应该是的3d矩阵。
数据来自流体流动模拟
在图像中它显示y = 0处的轮廓线,但我希望它显示在任何y位置,因此可以看到切片从完整的3d图像中取出的位置
答案 0 :(得分:2)
问题似乎是你的x3d和y3d被逆转了。
slice(y3d,x3d,z3d,L3d,[],[],[0.1 0.3 0.5]);
ax=gca;
ax.Children(1).LineStyle='none';
ax.Children(2).LineStyle='none';
ax.Children(3).LineStyle='none';
view(25,20);
colormap jet
colorbar
对于轮廓,只需给它一个值来绘制轮廓。
figure(2);clf
contourslice(y3d,x3d,z3d,L3d,[],[],[0.1 0.3 0.5],[10 20]);
view(25,20);
对于等高线图我发现了一个不同的解决方案。不像其他两个那么简单。
zax = squeeze(z3d(1,1,:));
zvals=[2 13 24];
figure(1);clf;hold on
for ct = 1:length(zvals)
%plot the contour
contourf(L3d(:,:,zvals(ct)),[0 10 20]);
ax=gca;
ax.Children(1).XData=x3d(:,1,1); %set x axis
ax.Children(1).YData=y3d(1,:,1); %set y axis
ax.Children(1).ContourZLevel=zax(zvals(ct)); %put at correct z
end
view(25,20);colormap
感谢Amro的回答:plot multiple 2d contour plots in one 3d figure [Matlab]
答案 1 :(得分:0)